Hello guys, I’m here once again to ask for help, because I’m terrible at Unity scripting
So basically my ship has a boost script that when I press and hold the spacebar, its movement speed is multiplied. Now I want a way to limit this boost as it will be overbalance if the player could just boost forever. So I want some sort of energy variable which gets consumed while boost is active.
1 second of boost = 25 energy;
Energy out of 100;
It will take some [variable] time to recharge this energy, lets say 5 energy per 10 seconds.
If the energy is 0, the recharge time is double.
My boost script
if (Input.GetKey("space"))
{
GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = true;
rigidbody.AddForce(inputMovement*acc,ForceMode.Force);
print(moveSpeed);
}
if(Input.GetKeyUp("space"))
{
GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = false;
}
}
Cheers guys,