Day 35: Adding Thrust
Objective: While holding left shift, speed is increased slightly.
To start we need to figure out where we would want to check for the input. Since it is the player that gets the little speed boost, so we’ll go to the Player Script
In the player script and under our movement function is where we would want to do this speed boost.
Before our transform.Translate() method, we want to check to see if the player is pressing the Left Shift key. We check to see if they are holding down the Leftshift, if so print debug. If not, stay at normal speed.
Now to increase the speed. We will use the same transform.Translate() that is used to move the player already. The only difference will be multiplying the speed by a speed boost.
Something we can do to allow for designers to adjust the thrust speed. We’ll need to get a serializedField reference.
We’ll replace the 3 in the check we did with this variable.
And that’s it. Now the player can speed up the player while holding the left shift key. Later on we’ll introduce a cool down system so players can just abuse this!