I am making a game and I made an animation for the win screen. According to all the tutorials I've watched, the animation is played when you activate the GameObject. However, it plays at the Beginning instead. I think the solution would be to play it separately when the game wins. Could you show me how to do that, please? Thank you in advance (:
1 Answer
When you create an Animation for a Game Object it's added as a State in the Animation Controller (Animator).
To Call a specific animation:
Option A:
You can use the Animator Component to play an animation at a specific event
Option B:
You can use Animator Parameters (Trigger or Boolean) to play the animation
animator.SetTrigger("TriggerName")
animator.SetBool("BoolName",boolean value)
In Order to use the Animator Parameters, you need to define the parameters and assign them to a specific transition
In this example Once the Boolean Die is true the Animation will occur (And in the script , you use Animator.SetBool("Die",true) once the health is zero)
3