input button is inconsistant

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

input button is inconsistant

Post by gblekkenhorst »

We're having an issue in our game where the select button only works about 20% of the time. useKey is set to 'E'. I put this in the proximity selector Update() to test it:

Code: Select all

            if(InputDeviceManager.IsKeyDown(useKey))
             Debug.Log("InputDeviceManager: " + useKey + " used");
            if (IsUseButtonDown())
                Debug.Log("UseButtonDown function fired");
            if (Input.GetKeyDown(KeyCode.E))
                Debug.Log("Input Get Key Down" + " used");
And this is the result in the debug.log:

Image

What could be interfering with the InputDeviceManager recognizing the E key?

The issue happens with both the Proximity Selector to start the conversation, and the UI Button Key Trigger on the continue button.

We are using Both input systems in our project.
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: input button is inconsistant

Post by Tony Li »

Hi,

The Input Device Manager assumes one input system is in use. Have you ticked or unticked the Dialogue System's Welcome Window > USE_NEW_INPUT checkbox?
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: input button is inconsistant

Post by gblekkenhorst »

The welcome window is set to New input system. We're using the new system for the character controller. The whole project is set to both as we have a few scripts that haven't been transitioned.

On the proximity selector, I have the Key set to E and the Button set to Interact, which is set to E in the inputactions file. (Althought I guess this is assigned to our character controller, I don't know where to assign it in DS?)
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: input button is inconsistant

Post by Tony Li »

Hi,

Are you using the latest version of the Input System package?

Also, if you open the C# script file Plugins > Pixel Crushers > Common > Scripts > UI > InputDeviceManager.cs in a code editor such as Visual Studio or Monodevelop and go to this method:

public static bool DefaultGetKeyDown(KeyCode keyCode)

does the "#if USE_NEW_INPUT" have colored syntax highlighting, or is it grayed out?
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: input button is inconsistant

Post by gblekkenhorst »

Input system is the latest, and #if USE_NEW_INPUT" is not greyed out..

However I checked in with my client about my open tickets, and it turns out neither she, nor any of our playtesters have ever had this issue?! So it's some kind of ghost only on my machine, so I'm just not going to worry about it for now.
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: input button is inconsistant

Post by Tony Li »

If you can get access to more machines to playtest on, that would be a good idea to gain more confidence that something specific to your machine is going on. Or maybe does it only happen in the editor's play mode? Maybe it's a Unity editor play mode issue.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: input button is inconsistant

Post by gblekkenhorst »

It's come up again, my client is feeling it and I've done a bunch of testing, including running the build on another computer and it's happening there. Unity registers the keypress fine, but Dialogue System is reacting weirdly. The problem goes away when when I turn off all the art in the scene and the framerate goes up - we're aware we have to optimize our art but is there any way to fix this in the meantime?

I'm currently testing this with ProximitySelector (as in my older post above) and UIButtonKeyTrigger. In UIButtonKeyTrigger I have the following:

Code: Select all

        private void FixedUpdate()
        {
            if (Keyboard.current.eKey.wasPressedThisFrame)
                Debug.Log("E is clicked in FixedUpdate");
        }
        protected void Update()
        {
            if (Keyboard.current.eKey.wasPressedThisFrame)
                Debug.Log("E is clicked in Update");

            if (!monitorInput) return;
            if (!(m_selectable.enabled && m_selectable.interactable && m_selectable.gameObject.activeInHierarchy)) return;
            if (InputDeviceManager.IsKeyDown(key) || 
                (!string.IsNullOrEmpty(buttonName) && InputDeviceManager.IsButtonDown(buttonName)) ||
                (anyKeyOrButton && InputDeviceManager.IsAnyKeyDown()))
            {
                if (skipIfBeingClickedBySubmit && IsBeingClickedBySubmit()) return;
                Click();

            }

  
        }
Debug.Log("E is clicked in FixedUpdate"); ran 156 times and
Debug.Log("E is clicked in Update"); ran 17 times

In proximity selector everything is in update but

Code: Select all

            if(InputDeviceManager.IsKeyDown(useKey))
             Debug.Log("InputDeviceManager: " + useKey + " used");
             // Runs 17 times
             
            if (IsUseButtonDown())
                Debug.Log("UseButtonDown function fired");
             // Runs 17 times
                
            if (Input.GetKeyDown(KeyCode.E))
                Debug.Log("Input Get Key Down" + " used");
                             // Runs 156 times
                             
So some update loops appear to be affected by the framerate (InputDeviceManager and UIButtonKeyTrigger) and others (ProximitySelector) are not?
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: input button is inconsistant

Post by Tony Li »

Hi,

Keyboard.current.eKey.wasPressedThisFrame is only accurate Update. The Input System (and the original input manager for that matter) update input values every frame, which is every time Update runs. If you're having performance issues and only getting 10 frames per second, Update will be called 10 times/second. If your fixed update runs at 50 frames per second, FixedUpdate will be called 5 times for every Update. So if the player presses E, wasPressedThisFrame will be true for one Update and ~5 FixedUpdates.

Are you perhaps using an old version of ProximitySelector?

The Update loop calls IsUseButtonDown(), which checks InputDeviceManager.IsKeyDown(useKey) and DialogueManager.GetInputButtonDown(useButton). It shouldn't be calling the Input class directly.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: input button is inconsistant

Post by gblekkenhorst »

All my debug logs are just testing to see how lag is effecting the input, I don't actually need any of those calls. I just wanted to test why dialogue system is missing input when the rest of the game mechanics don't. so far as I can tell, it's just the continue button and the proximity selector. Everything else in the game is using an input control scheme or Keyboard.current, and they're not missing input, even when the game is really laggy. The input bug wasn't effecting my client likely because her desktop has a way more powerful graphics card than mine, and the game graphics only recently became heavy enough to reduce her performance. We're working on optimizing the game art eventually, in the meantime I'm just turning off all the art when I need to test the dialogue system.

We're using 2.2.34.
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: input button is inconsistant

Post by Tony Li »

Have you enabled the Dialogue System's support for the Input System package? (From the Welcome Window, tick the USE_NEW_INPUT checkbox.)

Is the Dialogue Manager's Input Device Manager component > Always Auto Focus ticked?

Does your scene have an EventSystem that's configured with an InputSystemUIInputModule?
Post Reply