I’m building a space game and i’m trying to make my ship go different speeds depending what i need.
The ship is 3rd person right now.
example of what i trying to do:
reverse - stop - 1/4 - 1/2 - 3/4 - FULL
At present I can make it go forwards and turn however it’s just one speed and I have to keep the accelerate button pressed to keep moving, which I want to move away from.
What I want to do is make it go set speeds by just a button press without having to keep the button pressed all the time.
Any idea how I could set that up?
Any assistance or advice would be appreciated. Thanks
Also as a side note, my ship has a habit of dipping when I make a turn, How do I eliminate the dipping?
There’s a couple things you can do, depending on how you want the controls to feel.
If this is physics based at all, you should remove any drag or friction that slows the ship down over time. This way when you let go of the accelerate, you just stay at your current speed until you start braking.
If you want to hit exactly those speed increments, you can change the Accelerate button to change a “speed level” each time it’s pressed. So speed level starts at 0, first button press is 1 (or 1/4 of max speed), and so on. Pressing brake can do the opposite. The next step here would be to make the ship lerp towards the current desired speed level so that you still get a smooth acceleration.
I definitely like the second option, it’s exactly what i’m trying to achieve.
So speed level starts at 0, first button press is 1 (or 1/4 of max speed), and so on.
you mentioned using a lerp, I’ve not had any main experience with those yet. Do you know of any tutorials or links I could use to try and create this movement system.