- Home /
Animator.SetBool doesn't work first time
I have a script from which I change a boolean parameter in an animator:
if(toggle && Input.GetButtonDown("Fire2") && wType == weaponType.sniper)
{
//Animation
animator.SetBool("sniperScoped", !isAimed);
}
I then (in the same if statement) check if "isAimed" is true or false and call a function accordingly.
The problem I'm having is that the boolean parameter doesn't change the first time I right click. However, if I press it again, it works fine..
Does anyone know what causes this problem and or how to fix it?
Have you double checked that toggle isn't working against you here? (that is, is it false for some reason you're not expecting)
How about isAimed? Are you certain of the state of isAimed? Is it false the first time?
Answer by luiscmendez · Jul 10, 2018 at 06:48 PM
My guess would be that the problem stems from the bool isAimed. Without actually seeing where that value is being set, I have not way of giving a definitive answer.
A quick test would be to just hardcode the value to true or false. If it's still not being set the first time then it's definitely a larger issue.
Your answer