2D Shooter: Adding Shield Visual Effect and Animation

Objective: Add a visual element that will appear once the shield has been activated, disappear after a hit, and give it an animation.

Once we get the behavior of our shield working, we want to drag the sprite for the part that will be going around the space ship into the hierarchy. More specifically, you’ll want to drag it onto the player, so it becomes a child object.

You’ll also want to uncheck the box next to its name in the inspector. This is so that it won’t be on automatically at the start of the game.

Now for the coding, make a serialized variable for this object in the player script, and then drag it into the box. Now we can access to the object through code, and we can use the command SetActive(). We want to set this to true in the ShieldActive() method, and false where shields are deactivated.

Animated this should be easy! Select the object, create an animation file, click the record button, and drag all sprites you need for it into the timeline! Then you should be all finished after some tweaking to your heart’s desire!

--

--

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
Sabrina Windsor

Currently learning to code with the help of GamedevHQ in order to someday my my game ideas come to life!