Movement not working when enabling input

Hi,
So I’m running into this problem where I have a sequence where I set the input mode to UI only. I found that after the input mode is set back to game only, and the player was holding down the shift key (sprint) and a movement key (wasd) before the input mode was set back to game only, the player won’t be able to move in the direction until they release and press the movement/sprint controls again. I’m not sure why this is happening.

im guessing you’re setting sprint to false on button released but released wont be called because you disabled the input. might have to manually set them when you change UI mode

I put a print statement after the triggered event for the sprint key being pressed/held down and it prints out every tick. But after the whole sequence of disabling and enabling input, the print won’t fire until the player releases from shift and then presses/holds it again

are you using enhanced input? if so what does started/cancelled etc say?

Hey @Auran131!
I’m using enhanced input. What do you mean what does it say, though?

sorry i meant a print string, for instance does cancelled get called when you disable input

None of the events are fired when I’m holding down the shift key during the enabling of input. And also Cancelled isn’t called on disable input.

The weird thing is that it works fine for the wasd keys

can i see the code on the shift key?




The second image is the Shift Input Action and the third is the WASD input action. And the last one is the Input Mapping Context. The node itself isn’t firing so it shouldn’t be any logic that happens beyond it.

your saying walk works but run doesnt though, and the only difference is literally the key? just for testing try a different key, i wonder if the editor or widget has a problem with shift

Yeah, it’s weird. I changed it to the F key and it fires like it should. But if I press a WASD key, it stops firing the F key until I let go and press it again. But there is something weird with the shift where it won’t fire until it’s lifted and pressed again. But if I’m holding a WASD key before enabling input, the player will walk. But once I press the sprint key, the player is stopped in their tracks.

very strange, try removing the mapping context when you switch to UI mode and add it back when you switch back, maybe that will reset it

Nope that didn’t do it. I found this options struct which seemed like the answer, but it didn’t change anything. I unticked it but it didn’t work.

It seems like it only allows one input at a time. So If I hold W before enabling input and then press F, it fires the sprinting but stops the W until I release and press W again. And if I press F before enabling input and then press W, it will fire the walking but stop the F until I release and press F again. The Shift key is the most finicky one because it just won’t take any input if it’s being held down before enabling input.

only other thing i can suggest is try it in a packaged game, could be an editor issue

Yeah, I’m gonna go ahead and try that. I’ve also noticed that if you do the same process when hitting play in the editor, it has the same problem. It has something to do with the Input Actions getting controls handed to them.

Yeah that didn’t seem to do anything