Phase 1: Thrusters

Objective: Add thruster mechanics to the player.

So in order to get thrusters working we need to be able to adjust the speed. Like we did for the speed powerup, we will set a serializable private float to use as a thruster speed multiplier.

As an addition to making the player faster while thrusters are on, some visual feedback would be a nice touch. For this we set a serializable private game object for the thruster attached to the player and assign it in the inspector.

Thruster speed multiplier and game object

Next within the update method, we run two if statements, one to check if the left shift is pressed and the other if the left shift key is released. Each option calls to its specified method. Pressed calls the thrusters activate and released calls thrusters deactivate.

Activate and Deactivate methods

As you can see above, the logic between both is similar. In activate we multiply player speed by the thruster speed multiplier and deactivate divides. We set a Vector3 scaler variable and on activate set the thruster object attached to the player to the larger scaler and on deactivate, set the scale back. While scaling the object, the position slightly moves so we create a Vector3 thruster position and adjust the y position of the transform for cleaner presentation.

Thrusters activated and deactivated

In the next post, we will look more at the players shield behaviour.

--

--

--

Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Instance Variables and Cucumber Features

Shopping application with django and django-graphene

nextcloud reverse proxy http/https mismatch (SSO, LDAP config)

Microservices — An Architectural Strategy

An Introduction to Domain-Driven Design

Algorithm

Save 50% of platforms’ fees–if you are a small publisher

Why Every Company Should Care About Concurrency Bugs

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
Simon Leen

Simon Leen

Developer

More from Medium

Unity : use Raycast for move the Player

Making a 2.5D Character Controller in Unity Part 1

Shooting Enemies in Unity.

Spicing up our enemy movement