How can I trigger character Animation? (Mecanim)

Hey

So I have a character on Unity I made on Maya

I have one idle animation and then a death animation

I only want these animations to occur let’s say 1 minute after the beginning of the game instead of the animations occurring immediately.

How can I do this?

Alternatively, is it possible to add a trigger so that the death animation plays on the character after the trigger has collided with player.

What code do I need for this?

All the trigger based animation tutorials out there play animation clips but basically I want to play an animation controller of a character after a certain time or event.

Kind Regards,

Just create trigger in mecanim and add it to transition, so when the trigger is set, the transition will be triggered. To set trigger use animator.SetTrigger(“triggername”); when you want transition to be executed.

Just as @Maxpeinas said, you will have to set up a trigger parameter in the Animator Controller and use that to transition from state to state. I would recommend watching this tutorial from the Unity Learn site:

Additionally, the whole animation section is very helpful for explaining things like what you are trying to do.
Unity Learn: Animation. In the videos, the interface might look at bit different because it has changed over versions, but all the core functionality is the same.

Cheers,
TrickyHandz

or you can use animator.CrossFade(“animstate”,0.1f)
when triggered or timer>60

1 Like