- Home /
Question by
MSachs · Sep 05, 2018 at 06:45 AM ·
animationscripting problemanimatortrigger
Animation Trigger is saved even if it is not used immediately.
Hi,
I have a simple open and close door animation. It opens when right clicking on the door and closes when right clicking off the door. I am using a trigger for that. The problem is if I am right clicking off the door before right clicking on the door it kind of saves the click and when eventually right clicking on the door it opens but immediately closes again.
Is there a way to fix this or even a better way of doing this all together?
Thanks in advance
Comment
Answer by MSachs · Sep 05, 2018 at 07:54 AM
Just figuered out a way by using
if (anim.GetCurrentAnimatorStateInfo (0).IsTag ("1"))
{
anim.SetTrigger ("CloseDoor");
}
I tagged the "OpenDoor" animation as "1" so the "CloseDoor" animation only plays if animation "1" is played. It seems to work fine. If there are better ways to do this please let me know either way. :)