I have been doing simulations of a vessel. I wanted to model linear damping as close to some real life data that I have.
After tinkering around and seeing that results are not as I expected I ran a few tests, after which I discovered that linear damping (possibly angular also, haven’t tested that) does not work correctly.
Setup:
A static mesh actor 100 x 100 cube with a cube collider is set in a scene. Physics simulation enabled and gravity turned off.
The mass is set to 1kg and a linear damping rate is set to 1.0 to simplify. A force vector of (100, 0, 0) is applied every frame in the tick function. By PhysX definition of the linear damping, linear damping should apply an opposite force equal to velocity * damping rate. This means that the cube should achieve constant velocity at 100 cm/s.
Results:
The constant velocity is reached at 98.333 cm/s which is a difference of 1.667 from expected. I couldn’t help but notice that it resembles the frame time of 60 fps (0.01667 * 100), which my simulation was set to.
Further tests showed that making the framerate higher made the error smaller, and vice versa. Setting the max physics delta time to 0,066666 and framerate to 15 fps, resulted in max velocity of the cube at 93.333 cm/s, which is exactly 6.666 away from expected.
And finally, I tested it with gravity. Letting the cube fall freely under gravity, with no other external forces, still the cube being 1kg and damping 1,0. makes the cube terminal velocity equal to 980cm/s - 1.666cm/s, instead of 980cm/s.
Conclusion:
Damping is off and it has to do with the physics delta time. I also discovered that it varies according to the mass of the static mesh, which should not be the case per PhysX definition of linear damping. Precise simulation of damping is thus less than ideal with the built-in damping in UE4. I will proceed to make my own damping code because it is not complex, but this is something that should be looked into.