I have 2D “de-exponential” acceleration, meaning that at first the player will go from velocity 0 to velocity 5 in 3 seconds, but from 5 to ten in 7 seconds(not the exact numbers, but that is the idea)
My first idea was:
The problem, is if the speed is small, the player well get really big amounts of speed.
Make so that the start speed is high will not fix the problem, the player can still
deaccelerate, and when he is at a low speed start moving.
Next, I tried this:
For this one, I don’t how understand how to make it work, nor how to use Time.deltaTime on this.
Please explain how to use increase the player’s velocity in a de-exponential fashion.
If you’re doing this because you didn’t like your character constantly accelerating then you can add drag. Although the issue with rigidbody drag is that it applies drag on both the X and Y axis resulting in your character falling slowly. So instead you can apply your own drag on just the X axis:
void FixedUpdate()
{
rb.AddForce(Vector2.right * 5 * Input.GetAxis("Horizontal")); // move the player left and right with a speed of 5
rb.AddForce(new Vector2(-rb.velocity.x,0)); // add horizontal drag to prevent the player from constantly accelerating
}
You could have an acceleration schedule and a braking schedule, or deceleration schedule.
If you want to do it with formulae, such as your first one, and want to avoid the crazy-high initial values, just add an offset to your divisor, such as: