I used the InputManager to add another Axis called “Strafe”, setting Q to the negative values and E to the positive.
float thrust = Input.GetAxisRaw(“Vertical”);
float rotation = Input.GetAxisRaw(“Horizontal”);
float strafe = Input.GetAxisRaw(“Strafe”);
The problem I’m having is that if I’m holding both W and A, meaning going forward and turning left, then for some reason the strafe input won’t register for Q even though it registers E fine. ie, if thrust and rotation are both 1, I cannot get strafe to register a negative value.
Similarly, if I’m going forward and turning right (holding W and D), the problem reverses and I can hold Q to strafe left, but then it no longer registers when I hit E to strafe right.
Could anyone explain what’s going on here or what could be causing this? I tried switching up the “Axis” field on my Strafe input, but that didn’t do anything.
Could be a limitation of your keyboard. Most keyboards can’t detect all of their keys at once, and different keyboards have different limits of how many keys or what combinations of keys they can detect at the same time.
Could also be an issue with the code you wrote for reacting to the input.
I can’t think of a way you’d get this result by misconfiguring your input axes in the Unity input manager, but I won’t swear there isn’t one.
This is certainly a possibility and is broadly called key ghosting or key jamming:
https://en.wikipedia.org/wiki/Rollover_(key)
To see if this is happening, make a simple script that reads and displays every input you care about to separate UI fields, then run the game and fiddle the keys. You can see if any value you expect is either stuck or set at zero.
Keep in mind this behavior could be caused by the keyboard hardware, the keyboard driver, the operating system driver, or any of the myriad layers of mapping that goes on between your finger and the ultimate use of that value.
Oh weird I didn’t know keyboards worked like that. Yeah I can just open up a text editor and hold down any two buttons and some subset of the other keys will be disabled.
Thanks, for the answer!