GameDevHQ Crash Course#11 Animation and audio on trigger

Jason Dixon
1 min readMar 22, 2021

--

Beginning 2D space Shooter-Adding a death animation and a sound effect to our enemies

Simple right? just slap an animation onto the enemy and a sound effect and your good to go? not quite, we don’t want the explosion animation and audio to play as soon as they spawn in. So we need to have a trigger event for it to transition to the animation and play the audio. But if we have that both of those happen at the same time as it destroys itself we no don’t actually have the animation or sound play so…

Enemy Death Script

we need to put a little more juice into this one, our animation plays for 2.3 seconds so we can set it to destroy itself at the end there with our overloaded destroy method, we need to disable the collider on it otherwise it will continue to take bullets and collide with the player and we don’t want that for these enemies, the tag being changed and the death bool are set up for Future Jason when working with tracking enemies left. Your welcome Future Jason.

--

--

No responses yet