2D Spaceship Thrust Control in Unity Part Two

Objective: Add thruster animations to our main engine and side thrusters for left and right movement.

In part one we added some C# code to allow us to move our space up, down, left, and right. Now we need to add some animations to provide the thruster visual effects.

Thruster sprite sheet

Next, we create an animation.

To create an empty game and assign a sprite at the same time is as easy as dragging the first frame of the sprite into the “Hierarchy” pane. Next, add an “Animator” component and drag and drop the animator into it and drag it to the “Player “ in the Hierarchy and make it a child of Player.

Make sure the “Loop Time” box is checked.

Use the “Thruster Transform” to adjust the position of the Thruster Animation in relation to the “Player”

Adjusting the “Y” axis for proper position

Our main engine thruster runs continuously and does not need to be turned off and on at this point. The side thrusters do. We only want to see them when we are moving left or right.

The above picture shows the side thrusters added. To do this I created two more animations using the “Thruster” sprite sheet named “LeftThruster_anim” and “RightThruster_anim” scaled the thrusters to size and rotated them on the “Z” axis. I then moved both of them under the “Player” as “daughter objects” so they both move with the Player.

In Part Three we will add the C# code to turn our side thrusters on and off when we turn. Until then….



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