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.
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”
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….