How to make Airplane move forward faster INSTANTANEOUSLY?
So everyone knows it is easy to add force to a rigidbody, however this messes up my physics AND takes time to speed up the plane. Since I'm making a nitro bar for my game, that acceleration time is unacceptable. Also TimeScale won't work as it will speed up my game's timer (and probably mess with multiplayer in the future). So what's the best way to make the airplane move forward faster without waiting for acceleration?
Thanks :)
Answer by TreyH · Feb 14, 2016 at 04:35 AM
Consider adding ForceMode.Impulse to your AddForce calls (this will ensure your rigidbody's velocity value is always correct, as you're using the physics engine to accomplish your goal).
Alternatively, if you're set on doing it manually and your object is truly moving in its forward direction (assumed to be the case, as it's a plane):
if (nitroActive)
{
// Rigidbody attached
Rigidbody planeBody = this.transform.GetComponent<Rigidbody>();
// How much to boost by
float nitroBoostMultiple = 1;
// Total position delta to add
float speedBoost = nitroBoostMultiple * planeBody.velocity.magnitude * Time.deltaTime;
Vector3 positionDelta = planeBody.transform.forward * speedBoost;
// Add a multiple of its current velocity during this frame (scaled for time)
planeBody.transform.position = planeBody.transform.position + positionDelta;
}