Learning Unity — More Advanced Animation Practices

My static sprite, an image of an asteroid
My asteroid sprite transitions into an explosion animation
The Animator window for a new animation
The Animator window after creating a new empty state and making it the default state
A Transition in the Inspector window
  1. We need a triggering event. In this example, I have made the space key being pressed activate the trigger.
  2. We need access to the Animator component. In this example, I use the GetComponent method to access the game object’s Animator.
  3. We need to activate our trigger. This is accomplished by using the SetTrigger method of the Animator. The parameter for that method is the name of the trigger parameter.
Script for triggering the animation

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store