- Home /
Animation transition not recognized while holding multiple keys
HI. I'm trying to animate a character and I have set up an animator controller. I have 2 blend tree states , one for walking and other for running that should transition to "Jump" state and "runningJump" respectively when Space key is pressed. I have boolean parameter isJumping that is on a transitions for jump states. I have this code attached to my character that sets isJumping to true or false.
if (Input.GetKeyDown(KeyCode.Space))
{
anim.SetBool("isJumping", true);
}
else
anim.SetBool("isJumping", false);
The problem is that jumping states don't activate when holding certain keys. For example, It jumps if I hold W or UP arrow to move my character but if I try to jump while holding W and Q to move to the left it doesn't jump, but if I hold W and D keys to move to the right it jumps. It is other way around if I use arrow keys to move my character (it doesn't jump when I hold left and up arrow). Or when I'm holding SHIFT to make my character run instead of walk the runningJump state never activates.
I have no idea what could be wrong. It could be something stupid but I've been trying to solve this for so long that I don't know where to look anymore.
edit: I tried this on my laptop and it works. It might be that my keyboard sends wrong signals when holding multiple keys or something like that.
edit: I tried this on my laptop and it works. It might be that my keyboard sends wrong signals when holding multiple keys or something like that.
By "works" do you mean that the same bug appears, or that the bug goes away?
I think what may be happening here is that multiple keys being pressed at the same time is setting line 1 to false.
To be clear, I think that Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space)
may be read as Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space) && !Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Any$$anonymous$$ey)
To correct this then, you would just make a series of OR statements to check for each possible key combination that would activate your jumping.
That honestly shouldn't be the case, but when you're dealing with a class like Input resolving to a bool, you never know.
Good luck!
By works I meant that bug doesn't appear while using laptop, so I'm guessing it must be something with non laptop keyboard. Thanks for suggestion.