Creating Ship Thrusters

Blake Zoeckler
3 min readMay 24, 2021

Today we’ll start adding some additional features to Galaxy Shooter. The first thing to change is how the player moves. Lets make it more exciting by allowing the player to activate thrusters and move much more quickly.

We’ll need a button for both keyboard and controller that will cause the thrusters to activate. In the Input Manager, we can add “Thrusters” as a new axis that can be controlled with code.

The 9th axis is a joystick’s left trigger. For keyboard users, there’s another “Thrusters” button set to left shift.

Now we’ll need a few new variable for our Player script. _thrusterSpeed controls how fast the player’s ship will move when thrusters are activated. _thrusterTransform which will keep track of a thruster gameobject so we can change it’s size by _thrusterSizeMultiplier.

We can also rename some variables we had already. Most IDE’s have a refactor option that allows us to rename variables and automatically change all the references to that variable, so we don’t have to hunt down every single reference and change them all manually.

Now we can change CalculateMovement to update the speed based on whether thrusters and/or speed powerups are active.

Now the player can move faster in game. However, when controlling the size of the thruster image, we have a problem.

Making it smaller causes it to disconnect from the back of the ship. To fix this, we can attack it to an empty object that will act as its pivot.

Now when we select this pivot object, and use its pivot position, we can scale it from the back of the ship, so the image lines up no matter what size it is.

Once we assign everything properly in the inspector, we are all done. Now we have a lot more control over movement, and it looks a lot more dynamic as well!

--

--

Blake Zoeckler

I’m a passionate and talented software engineer seeking an opportunity in game development.