- Home /
Less acceleration as racer speeds up?
I'm wondering how to do this. I want different racers with different max speeds, but I want gameplay to be balanced. The racers are currently hinged on acceleration, speed, and max speed. As the title says how do I go about making the racers comparable to each other?
Answer by Rennat · Dec 03, 2010 at 04:32 AM
The way I've handled this is to curve the amount of acceleration added by the speed of the racer, something like this:
y = (x - 1)^2
the racer's speed divided by his max speed is x
, a number between 0 and 1 (inclusive.) which once put through that equation gives you how much of it's acceleration the racer gets to use. So the closer he gets to his max speed the less he gets to accelerate.
here's how you'd get that in javascript:
var x : float = currentSpeed / maxSpeed; var y : float;
if (x < 0) { y = 1; } else if (x > 1) { y = 0; } else { y = Mathf.Pow(x - 1, 2); }
currentSpeed += acceleration * y;
BUT you'll still need to balance each racer's speed and acceleration to make it fair(ish) A racer with a higher top speed might have a lower acceleration so it takes him longer to get to his top speed.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085503im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Accelerate slowdown Player movement 0 Answers
Changing Speed in Gameplay Affects GUI 2 Answers
Acceleration of Transform in FixedUpdate (SOLVED) 0 Answers
Movement/Acceleration problems 1 Answer
2D Collect Item C# Increase Acceleration 2 Answers