CCD causing incorrect bounce angles

Hello, we have been experiencing strange behavior in our game when using CCD on a physically simulated simplified sphere collision. It appears to calculate the bounce angles incorrectly.

Here are a couple of videos to demonstrate:

CCD ON:

CCD OFF:

As you can see in the CCD ON video, the ball bounces directly upwards upon hitting the hill. This same behavior happens when impacting walls as well.

Here is another clip showing this:
https://streamable.com/o3cik

Other notable settings:

We needed very low contact offset settings in order for our ball to roll over hills smoothly, I’m not entirely sure how these work as there isn’t really any documentation that I can find. However I should note that using higher values reduces the incorrect bounce behavior but does not eliminate it. In return we get a ball that bounces up oddly when rolling over smooth hills(seems to bounce at the edge where 2 tris meet). Using low values fixes these issues but increases the incorrect bounce issue(but only when CCD is enabled).

Contact offset multiplier: 1.0
Min contact offset: 0.0001
Max contact offset: 0.001

Substepping: [x]
Max Substep Delta Time: 0.016667
Max Substeps: 6

If anyone has any info on this that could help it would be greatly appreciated, thank you.

Hey,
I think the result is correct :-), this is just a way how CCD works, it just colliding with everything on the way… and then it generates such results, it probably collides with the ground multiple times and this makes it to bounce upwards same with the walls - it collides with the wall and the ground so it goes upwards :frowning: ,I could maybe advice to use a line trace each frame to position the ball smoothly with hills - hope it helps.

I don’t believe the way it is bouncing is intended behavior, I’d rather not do any kind of hacky work around either as that can lead to weird behavior down the road and isn’t really a viable solution for us.

Would like a solution to this if anyone has ideas for a real fix.

Can you show the collision mesh of the sphere?

There is no collision mesh, it uses a simplified sphere with a radius of 4.2672.

Hello, I’m posting an update on this for anyone who may be experiencing similar problems.

I found this thread on the nvidia forums:

To me the issue sounded like it may be a similar problem, perhaps our ball was penetrating 2 faces at once at a meeting edge.

In this file:
https://github.com/EpicGames/UnrealEngine/blob/f794321ffcad597c6232bc706304c0c9b4e154b2/Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/GeomUtils/src/GuBounds.cpp#L400

Changing the constant inSphereRatio to 0.65 seemed to help quiet a bit, the ball no longer bounces straight up on our hill shown in the original post.

However we still have issues in more extreme scenarios, such as a loop for the ball to go around. As the physics of a loop require the ball to be going fast enough to counter gravity, this results in it constantly pushing against the loop surface. My theory is it’s just creating the original scenario of the hill in a more extreme way, seeing as it is touching 2 faces at once multiple times as it traverses the loop.

Before changing that constant to 0.65, this was some what verified by launching the ball into an angled flat plane, the issue never occurs as it is a single face of 2 tris with the same normal. And it did seem to only appear along concave edges.

Hope this helps someone.

Glad my suggestion helped you to ge the right results.

After a huge headache of trying to fix it I decided to go with your suggestion of running a trace. Seems to be working pretty good. I calculate the next position based on current velocity / frame rate, and run a trace from current to that position, if there is a hit I then use the hit result to determine where the ball should be on the next frame.

https://streamable.com/bnw2f

Loops are now working too :). Ignore the error at the very end. Thanks!

Would you like to share this project?
It is very helpful to me