The animator’s parameter for when I release the key does not turn to true if I release it really fast. Do you know why? Here is my code and animator transitions.
- This is in my moveScript
public void CharacterAim(bool isAiming)
{
anim.SetBool(animStrings.isAiming, isAiming);
}
public void CharacterAimRelease(bool aimRelease)
{
anim.SetBool(animStrings.aimRelease, aimRelease);
}
void Update()
{
moveScript.AnimateCharacter(Input.GetAxis(input.forwardInput));
moveScript.Running(Input.GetButton(input.runningInput));
moveScript.CharacterAim(Input.GetButton(input.aimInput));
moveScript.CharacterAimRelease(Input.GetKeyUp(KeyCode.Z));
}
Debug it… debug your animation transitions so you know they work correctly before looking to the code.
You might be pressing and releasing the key in the same frame, if that’s even possible. At least eliminate that chance by gathering all the input into temp variables, printing them, then acting on those temp variables.
You can also debug the input stream by replacing it: make an array of the inputs in code and send them off to the animator super-fast every frame, perhaps restarting the entire sequence by pressing another debug keypress.
(By that last paragraph I mean stream infalse, false, false, true, false, false
all in a row and make sure the animator does what it should. If it doesn’t, you might need to buffer or delay the input intents.)
This reads like a flawed approach where you have two bools for one binary action.
The character is either aiming or isn’t. There is no aiming and release aiming, those aren’t separate actions. Imagine a typical game where you pull down LT on the gamepad to aim down sights. Is this two buttons or one?