Our engines are down.

Chance Cornell
3 min readJul 21, 2021

In our final article about visual effects on the space shooter game, we will be adding thrusters to the player, as well as damage indicators.

First, the thrusters. We want the thruster to move with the player, just like the shield that we built. All we need to do is drag the first sprite of the thruster animation to the ‘Player’ game object. You will have to change the scale to read ‘1’ all the way across, and then position the thruster at the tail of the player. Then with it highlighted, create a new animation. Let’s name it ‘Thruster_anim’. After that highlight all the sprites in the sequence and drag them to the dope sheet. Press play in the animator and see if they work. If they do, then play the game and see it in action.

Let’s give the player some feedback for being hit. In this project, I will be adding damage to the engines, on the left and right of the ship. I have a series of sprites for an animation that I will be using. First, drag the first image of the animation to the ‘Player’ since we want it to move with the player like the thruster. Rename it to ‘Right_Engine’. Next, create the animation for the engine failure by doing it the same way we have been. Now, duplicate the ‘Right_Engine’ and call the other ‘Left_Engine’. Deactivate both of them for now. We will activate them in our ‘Player’ script in a moment. We will probably have to move the ‘Sorting Layer’ to ‘Foreground’ and set the order to 2.

In the ‘Player’ script, we need to create serialized GameObjects for both the left and right engines. Name them ‘_leftEngine’ and ‘_rightEngine’. When we go back to Unity we will need to drag the game objects to these slots.

Under our ‘Damage’ function after we start subtracting lives when hit, we need to create an if statement that says if ‘_lives’ is equal to 2, then we SetActive the right engine. Then, else if, ‘_lives’ equals 1, then we SetActive the left engine. Our ‘Damage’ function looks like this now.

That is it. Both engines should show when damaged to their variables.

--

--