How do you apply friction or drag to the Physics Ball?

I’m trying out the new Unreal’s Rolling Ball template to create something similar to a billiard game. When I applied impulse on the ball, it rolled correctly. But after some distance even in very very slow speed the ball keeps on rolling. So how to make the ball stop smoothly on slower speeds? (similarly how a billiard ball stops at slower speed). Any kind of angular drag setting?

On the physics object properties there is a angular damping and linear damping setting. Playing with these will reduce the ball’s velocity over time. However, the ball does tend to continue to move when the velocity gets very low. It is very minor but problematic for something like billiards.

I am not aware of any settings that indicate a threshold for the low end of the simulated velocity. You can though create a test on this in the Event Tick. For instance, you can get the physics linear velocity of the physics mesh, break it into floats, compare it to the previous frame’s float values you store as a variable to see if it is below an acceptable threshold (usually .01) and if it is then set the linear velocity of the ball to zero. I can probably make a blueprint for it if that doesn’t make sense. Hope it helps.

it will be clear and helpful if you can create the blueprint and share it. Thanks

I looked into this a bit and the issue appears to be that the physics linear and angular velocity when lower than about 75 will decrease at lower and lower steps, essentially making it impossible for the velocity to ever reach zero. To accomplish the slowing effect then, you need to evaluate the current length of the linear and angular velocity vector on tick. When the values get to a cutoff point, you then initiate a stop event that will lerp the current linear and angular velocity to a stopped state over time. See the blueprints attached. You will need to have some state evaluation in there as well on whether the ball is moving, should be stopped, etc.

It seems to me this is a bit of a bug in the physics, not stopping entirely because of the stepping. Supposedly the Sleep Family should put the object to sleep based on some set thresholds (Is the built in physics good enough to make a simple billiards game? - World Creation - Epic Developer Community Forums). Unfortunately I found that the Sensitive and Normal don’t really make a difference and these likely need to be adjusted in source. I might take a look at it later, but I don’t have the time to investigate it that deeply. This approach should allow you to stop the ball well enough. Ideally you would use a log to slow the ball rather than a linear stop. If I have the time I might do that, or you can and repost. :slight_smile: Hope this helps.

Hi,
i know its an old post but still a very actual topic in 4.7

im working on a billiard game for testing purposes and i have exactly these problems.
playing with the damping values will slow down the velocities but never stop in movement.

is there something from the official side?

best regards,

Hello,

The thing about a linear dampening component is that it never goes to zero.
its of the form:

v’ = -av, and its solution is of the form v ~= 1 - e^-at.

You might want to add a constant dampening component by subtracting a very small speed, times the unit vector of your velocity and delta-t, from the velocity every tick. If the delta-v is greater than the velocity, just set the velocity to zero so it doesn’t roll backwards.

the custom sleep family option seems to work for me . set it a bit higher

I know this post is old, but I would like to know if that is still the case in 4.11? I’m having trouble making sure a simulated body stops completely by itself. Should I use that workaround too?

Hi, I’m just wondering if this still works, because with the current setup I have, I’ve what you’ve done, but it seems when the alpha hits 1, and the linear velocity should be 0, it does this thing we’re it suddenly makes it move in the over direction a little bit, then it gets slowed down again, and does the same thing, moves it in the over direction. Basically when its supposed to be stopped, it doesn’t and causes this continuous move back and forth

Also the main thing is the alpha is just constantly going higher, with the blueprints you’ve shown, you never set it back to 0? So what about when it starts moving and slowing down again, it “should” instantly just stop, but even then it still seems to do the continuous moving bus

It works way better without your lerping and just having sleep family option when it naturally gets to that slow infinite speed it just stops, works better, so unless you can give me a fix to yours, which seems to have a problem with lerping correctly, it works well just to use standard friction and sleep option

I find that just checking the velocity produces the same effects with less spaghetti. Just get object velocity, check if it’s below a threshold, if it is set the velocity to 0.

To apply drag to a vector directly you can do the following:

void ApplyDrag(ref vector, float delta, float drag)
{
    velocity *= (1 - delta * drag);
}