Hey guys! I need help with an afterburner overheating script for a game.
The player controls a spaceship, and with shift, he has the ability to use a 1.5 second boost, after what it will take 3 seconds to cooldown.
Now I want it to act like a real heating machine gun / engine, as in you can use it for 1 second, let it cool a bit, and use it again. But if you go over the 1.5 second threshold, it will need to cool down. If possible, I’d also like to display the percentage of heating.
I realise this might be very complicated, soI’m kind of clueless on how to proceed, could anyone help?
In C# if possible, thanks in advance!
Make a variable like float thrustSecondsLeft=1.5f;
Whenever you’re thrusting, subtract Time.deltaTime
from it. Otherwise add, up your max thrust seconds.
Logically, you can thrust when it’s greater than 0, but that would allow players to hold down all the time for a jerky 1/2-thrust (build up 1 frame worth of time, use it, … .) So maybe say you can only begin a thrust when 0.5 or more. Or, if they hit 0 they have “damaged it” and it drops to -0.5.
If you want to be really cute, you can play with the MAX. Let them build up a big one: at full thrustSconds, you could slowly build up to 2.5 seconds left. Or make it wear out with frequent use: Using thrust gives a tiny decrease to the max, which quickly “heals” back to 1.5 when at max.
For showing amount left, look around here for how to do a life bar.