- Home /
How to check if trigger from mecanim is true or false.
I am understanding that triggers and booleans are the same but a trigger turns itself off after it is fired. Right now I have it so when I click my gun shoots but the way I want it is so that when I click and my reload animation is not playing then shoot. But the problem is the isPlaying does not work because the animation is in a child's animator. The way I currently have it is that I have a trigger in mecanim that is named reloaded so when it's true it plays the animation. Well now to solve my initial problem I have come to conclusion that I need to check if the reloaded trigger is true so I can check if left click is pressed and the reloaded trigger is false then shoot. But I cannot figure what I have to do to check if the trigger is true or not. Please help with this.
Answer by drex150 · Aug 02, 2014 at 06:38 PM
What you need to do is use anim.getbool.
So something like this:
if(anim.GetBool("reloaded") == false)
{
//do stuff
}
If the animator is on a different gameObject you will need to get the component from that gameObject.
//Set object that has animator and then call the animator.
objectAnimator = objectWithAnimator.GetComponent<Animator>();
//Now you would call the bool.
if(objectAnimator.anim.GetBool("reloaded") == false)
{
//do stuff
}
I don't believe the ".anim" is needed in the line above.
if(objectAnimator.anim.GetBool("reloaded") == false)
Should be:
if(objectAnimator.GetBool("reloaded") == false)
Your answer
![](https://koobas.hobune.stream/wayback/20220613155626im_/https://answers.unity.com/themes/thub/images/avi.jpg)