Is it possible to have a forever bouncing ball?

I tried disabling all friction , setting restitution to 0 , disabling linear, angle damping, but the ball is still losing momentum as it’s bouncing.

I read in an old post that this is impossible in ue, because of some engine calculations, is that true?

you could just periodically add force?

Bounce => wait one frame => Set Velocity with:

  • restitution should be set to 1…
  • it should also be overridden to Combine Mode - Max, otherwise you take the other physical material into account as well. If there’s none, I believe a default value of .3f is used (but don’t quote me on this one :innocent: )
  • and there can also be a matter of using a Projectile Movement Component for bouncing which may, potentially, introduce additional inconsistencies… or amend them.

I let this run for 10 minutes:

  • no gravity, no damping, no physical material override, no script
  • initial velocity 5000
  • PMC:

Even though it does fluctuate (floating point error?) It always (as far as 10 minutes = always) resets itself to the initial velocity, as if there was a correction mechanism at play already - which I do not like much, interestingly enough.

Again, that’s without me trying to do anything about it. If I add this:

It (10mins) never fluctuates. No Delay Until Next Tick needed, however there might be an edge case scenario where it makes a difference.

2 Likes

Yes, sorry, I meant I set restitution to 1.

OK, thanks a lot for this, will do some tests and see if it works!

1 Like

The sphere is constraint to XY and yet it still managed to bounce up and escape on me once somehow. Yay, physics! :person_shrugging: I sense it does not like hitting the character capsule which has a movement component of its own…

Nope, setting constrains on the PCM fixes it up and makes sense since it’s the component that does the heavy lifting here. I also tested it with additional projectiles.

In my project I am trying to make the sphere bounce vertically, I feel like the solution of setting the velocity wouldn’t work here?

Why not? It works even without setting velocity. Do you have gravity on? Here’s what I’m getting:

Not overriding velocity.


However:

Consider providing details of the setup and testing methodology.

1 Like

Yes, I do have gravity on, the ball is just bouncing on the surface and I was under the impression that if I set restitution to 1 it will bounce forever.
Again - thanks for the detailed response, I am afraid I must have been clearer in my question :slight_smile:

What kind of inconsistency are we talking about? I’m getting the exact same behaviour as before. I let these bounce for some time, measured deltas and yes, without an override, there is the very expected floating point error which, again, gets corrected by itself (Epic’s code buried somewhere):

You may need to provide details. I sense there’s something critical we do not know - we do not even know how you’re testing it. Consider providing steps to reproduce the issue.


For example, there is this thing and it’s non-zero:

If your BouncyBall inherits from character class, it will be affected by it.

The ball and the ground have the same material.

In this image top left shows the impulse vector length on each bounce. It loses a little bit each time it bounces.


Physics settings, I tried locking rotation and position (xy), that fixes the ball going off from its position, but the inertia loss is still there.

Is this a loss at every bounce:

image

?

Yes

So you’re not using the PMC, just pure physics. Is this correct?

Yes, just a sphere with ‘Simulate Physics’ turned on and a static floor.

Well, I am generating the mesh using Geometry Scripts BUT exactly the same thing happens if I do it with the default sphere and floor.

1 Like

Not sure what’s causing this, probably one of those:

https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-settings-in-the-unreal-engine-project-settings?application_version=5.0

Will have a look in spare time, this is uncanny behaviour that does not manifest with the PMC which still relies on the old PhysX implementation (someone corrects me). I miss the time where it was just PhysX as opposed to this strange amalgam of Chaos and PhysX.

For now, you can fix it with this script - seems to make it consistentish:

Essentially, we capture the fist bounce and enforce it. Not sure if applicable.


Perhaps someone reading this, (cough, @Auran131, cough) feels like digging through / diffing the deprecated code…

1 Like

sorry https://www.youtube.com/watch?v=bWcASV2sey0

1 Like

Async Ticking Physics with Substepping fixes it. UE v5.5.4


Not sure how good this solution is - experimental feature, although I’ve been using it for half a year or so. In my understanding, the issue was not present in earlier engine versions. Definitely not in UE4.

2 Likes

Thanks!

The velocity capture works great!

Of course, it would be ideal if this worked on it’s own, so I could bounce balls on top of each other etc., but at least it’s something :slight_smile:

Does the Substepping solution work consistently? I noticed that sometimes it did, but then without me changing anything, it didn’t.
Also if I do it this way there is a noticable slow down of the simulation, what do you think is the best way to ‘speed it back up’? Gravity? If I choose to use Substepping.