Adding Thruster Feature to the Spaceship
Make player faster
Objective: activate thruster when player presses the shift key
In this challenge we are gonna give the player a speed boost when he presses the left shift key and deactivate the thruster when he releases the key.
We have to create a variable to have the reference to the thruster object (and assign it in the inspector) and another variable to manage the extra speed for the player.
Then we have to add the extra speed variable to the calculate movement function, adding this variable specifically in the transform.Translate speed calculation formula.
Finally we have to check for the left shift key in the update function to activate and deactivate the speed boost and the thruster.
And that’s all! We can activate the extra speed using the shift key.