Simple rigid body free fall results in correct velocity but not distance?

Hi all,

I am having a pretty basic issue that I hope is just a simple mistake on my part. When letting a simple 1m^3 rigidbody block fall, I am finding that the block is not displacing quite fast enough. I am logging the distance from the objects start point, velocity, and corresponding time to the console for every fixed update via script. The logged velocity agrees to three or four decimal places to what you would predict using the classic v2 = v1 + at equation, but the expected distance for that velocity and time are off what you would predict using d = v1 + 1/2 x a x t^2. In this case for example with gravity at -9.81 m/s^2, the velocity at t = 1.7s is 16.67699 m/s and the distance is 14.25883 m. Using the classic kinematic equations you would expect a velocity of 16.677, but a displacement of 14.17545 m. I have no drag applied to the object, so I am curious as to why this value is off about 8 cm over just 1.7 s of free fall. The velocities agree fine, so does this mean Unity is not using the traditional kinematic equation for displacement of an accelerating object?

Any help on this would be much appreciated!

Well since the question got bumped already I’ll post an answer. I’ve explained this already in my answer over here in detail. However to sum up what is happening I will go a bit more in detail.

First of all you have to understand that all our calculations happen at discrete time intervals unlike reality which essentially performs continuous integration. So every variable involved will only change at discrete timesteps. We generally use Time.deltaTime to fix for variable timesteps. However we can only fix linear equations that way. For a quadratic or more complex relationship this doesn’t really work very well. The error gets smaller the higher the framerate gets.

As I explained in my other answer since the delta velocity is a linear change over time we can simply use deltaTime to move from a frame based to a time based relationship. The pure position change is also a linear relationship. Each second we add “velocity” to the position to get the new position. However when we change the velocity as we’re moving it’s no longer a linear relationship. Linear means we just assume that the value is essentially the same over that time period and we just linearly scale it depending on the time passed.

Using the “right” formula for a constant accelerated movement wouldn’t make much sense for a rigidbody simulation since the acceleration and forces you usually work with are by no means constant. Yes, gravity is but once you reach the ground you are stopped by the ground.

Have you solved your problem?
I asked Unity but did not get useful information.