Creating Enemy Explosions

To play the above explosion animation when an enemy ship is hit by our Laser, we’re going to set a ‘trigger’ that activates an animation from the Animator.

First, we need to create a new Animation and drag the animation frames onto the animator. Now that we’ve created our animation we can edit the Animation Controller and add a new Trigger. We can create an ‘Empty’ state in our Animator and attach it to a Transition that uses the Trigger to activate the explosion animation:

Now all we have to do is add the trigger activation to the OnTriggerEnter2d method of the Enemy class:

As soon as SetTrigger executes, the new explosion animation will be played.

--

--

--

Unity and Flutter developer interested in creating mixed-reality applications.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Advanced Android Programming With Kotlin -Part 2

Navigating through a Reactive Android MVVM — Chapter 2

When load url show Error : java.security.cert.CertPathValidatorException:

Explore the New Layout Inspector in Android Studio 4.0

Implementing AdMob and Audience Network Libraries In Android

brightly lit neon signs along a Singapore street

Dynamic Lottie Animations on Android

Android Data Binding With MVVM: Using StateFlow and ViewModel

View of Earth from space

Progaurd Settings for External Libraries

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
Richard Morgan

Richard Morgan

Unity and Flutter developer interested in creating mixed-reality applications.

More from Medium

Unity Tutorial — Toon Shade in HLSL

Quick tip — Upgrading your Unity project to Universal Render Pipeline (URP)

Moving Platform and Lives

How to Win the Race Using Director