Download

Trying to better understand Linear/Angular Damping

Hi,

I have been trying to better understand how parts of the Unreal Physics system works so that I can more accurately implement them in my projects. I have lots of questions :wink: about them but for now I thought I would start with Damping.

I understand what damping is doing on basic level adding “Drag” to an objects linear motion, but I was trying to understand what math is used to create this drag. I am no programmer, so I did a bunch of googling and found that often people seem to use object Velocity * DampingAmount * Mass to get linear damping force. (Some people also talked about getting an objects cross section area that is facing in the direction of travel and air pressure and including this in the calculation)

Anyway to try to figure out what was used in the Linear Damping “Force” Calculation I created this basic setup…

Its a pretty simple setup, the blueprint cylinder on the left takes the objects velocity and multiply’s it by the linear damping value (I make this negative so the force is applied against the object) then add this result to the add force node. The other cylinder uses unreals linear damping setting in the physics properties. I set both Mass to 1KG to help remove the need to multiply by mass. When you run the simulation, gravity pulls both object to the ground and I see if they hit at the same time. Then change both linear damping values and run it again.

The results below…


As you can see the blueprint always hits the ground first (but obviously the difference is bigger as the value grows) I figured this might be to do with unreal doing a calculation based on object size to mimic surface area resistance. but I tried the tests again with different sized objects but the results were the same.

Basically, I am just trying to understand what is likely to be causing the difference? Is it something I am missing in the math? or is it something to do with the blueprint update tick?

I also did a similar setup for the angular damping…

Its much more difficult to test angular as “Spinning” motion is more difficult to tell if they are matching, but I found that the results where very similar between the blueprint and the “Standard” unreal physics.

One thing that was really odd was I had to tick Accel Change in the add torque node, if I did not the results would not match. I was under the impression that “Accel Change” ignores mass but since the mass is 1 I figured this would already be the case, making the “Accel Change” negligible.

Sorry for the very long post, I hope that its easy to follow. If anyone has time to explain how this works I would greatly appreciate it.

Thanks
Chris

Incidentally I am wrapping a blog post covering physics and will post link … in the meantime:

The rates at which rigid bodies dissipate angular and linear momentum are governed by damping rates. In the PhysX SDK two damping rates may be specified for a rigid body:
void PxRigidDynamic::setLinearDamping(PxReal linDamp); void PxRigidDynamic::setAngularDamping(PxReal angDamp);
With a linear damping value of linDamp a rigid body will experience a damping force each update equal to -linDampvelocity. Similarly, a rigid body with damping rate angDamp will experience a damping torque -angDampangularVelocity. The damping forces and torques always act against the velocity and angular velocity and are applied in a way that ensures that a moving and rotating rigid body will asymptotically approach the rest state in the absence of other forces.

Taken from:
https://documentation.help/NVIDIA-PhysX-SDK-Guide/RigidDynamics.html

Hi OptimisticMonkey,

Thanks for the reply, the link to the Nvidia PhysX stuff is really useful. Also would love a link to your physics discovery’s when you have them online, Thanks!

I think that I applied the force in the way they are describing in the PhysX Documentation, so I would have expected them to fall at a more similar rate. Hmmm. I just thought… “what about the blueprint tick group settings” and rushed off to try changing that from Pre-Physics, to all the other settings but sadly it did not seem to help either.

In general, I think your results look correct? - the damping force applied is greater for higher velocities which causes a higher delta between the two -

I often envision dampening causing the bodies to behave more like they are underwater… the higher the values the more resistance.

Hi OptimisticMonkey,

Yeah I totally agree, Linear damping behaves as I would expect too, as you say higher values = more resistance/drag. The issue I am having is that I was trying to recreate the Unreal Physics Linear Damping effect in a blueprint to better understand the math that is used.

I set up a very basic test scenario…
Unreal Default Cylinder with enabled simulate physics On, Mass at 1KG, Enabled Gravity and Linear Damping set to a test value, for example 1.
I then setup a blueprint with a Cylinder as root component, Enabled Simulate Physics, Set Mass to 1KG, and Enabled Gravity. So the same as the other cylinder but on the blueprint Cylinder I set the linear Damping to 0 and in the Event Tick I did the PhysX equation (-linDamp*velocity) using blueprint nodes. I set both cylinders 20m above ground level and then Played in Editor. Both cylinders fall towards the ground with the force of gravity.

So I basically expected the outcome of this test to be both cylinders would hit the ground at the same time, but as you can see below the results differed between the blueprint (left cylinder) and the unreal default cylinder. (right cylinder)

Hi all,

Since this post I have been trying to figure out how to get the max speed of an object with a constant force applied to it (using add force node). So it seems that…

Max speed (Velocity in m/s) = (Force*Mass)/Linear Damping

This pretty much equals the result in unreal (when using Unreals physics linear damping setting found in the rigidbody under Physics section).

Which seems to make sense as OptimisicMonkey highlighted, the physX documentation mentions “With a linear damping value of linDamp a rigid body will experience a damping force each update equal to -linDamp*velocity”, so max velocity should equal Force/linear damping (I think :-S)

Sadly this does not help explain the tests above, I feel that the discrepancy is probably something to do with blueprint tick and when things are calculated but I have no idea how to fix that or even test it. If anyone has any insights I would greatly appreciate it.

hmmmm… now I understand what you are trying. (sorry took a while to reply)

I tried replicating and am experiencing same results for linear damping.

Interestingly, I can counteract gravity perfectly by applying a force every tick of mass * 980.

But if I apply a force every tick of Dampingmassvelocity it seems to be slightly less than setting damping to the same value (10 in this case)

The source for Physx is available… might try to download and step in… if I do Ill let u know

Thanks OptimisticMonkey if you get the time and manage to find anything out, I would love to know your findings, thanks.

CarvedPixel,
I am interested in your experiments. I have wondered how this is implemented but have tried to ignore it and calculate my own drag forces. This was working well until…My experience is that I have a physics driven helicopter that works quite nicely in version 4.15 but I thought it was about time to move on so I updated to 4.21 and now the helicopter is badly out of kilter. something has changed in the way the engine does its physics calculations. You do not say what version of the engine you are using but I am certain that there is a change. The one warning I got in 4.21 on compiling was that ‘add torque’ was now deprecated and I should use ‘add torque in radians’. This I have done, the nodes have the same inputs. But, torque is a couple measured in Newton Metres. To try to express torque in radians is ridiculous. It just does not make sense. I do wonder what is going on.