How do I add acceleration to velocity?

You're right that acceleration and velocity have different units - but ultimately it all works in the same way.

Let's say there's a test where a ball rolls a certain distance along a ruler (measuring in inches) over a time period of five seconds (t=0 up to t=5).

At t=0, the position of the ball is "2 inches" on the ruler. At t=5, the position of the ball is 12 inches. The ball's position has changed by 10 inches per 5 seconds - or 2 inches per second.

Now let's consider the same thing, but instead of measuring the position of the ball over time, we'll measure the velocity of the ball over time (so we can't use a ruler like before, but let's pretend we have a magic speedometer instead).

Let's forget all about the previous test and what positions it used.

In the new test, at t=0, the ball's speed is +5 inches per second. At t=5, the ball's speed is +15 inches per second.

Like before, we can say that the speed has increased by 10 inches per second - over a time period of five seconds. This is the same as "2 inches per second per second," which is what people mean when they say "2 inches per second squared."

SO! In your update function, you can increase your position value by adding velocity*deltaTime to it. If velocity is one, then you're saying "increase the value by one unit per second."

Can you figure out why "n * deltaTime" is equivalent to "n units per second" when it's used in your update loop?

Anyway, you can increase your velocity value in the same way. Remember that velocity already represents "something per second," so when you add n * deltaTime to it, you wind up with your "per second squared."

Short version: Just add your acceleration to your velocity in the same way that you add your velocity to your position.

/r/gamedev Thread