Rolling ball jumps on flat surface

[=“, post:21, topic:37461”]

I can also confirm that the behavior has changed from 4.19 onwards and MaxContactOffset only has a limited impact. Looking at the source code it seems the problem comes from a line in FBodySetupShapeIterator::ForEachShape in BodySetup.cpp. In 4.19 it looked like this:


const float ContactOffset = ComputeContactOffset(Geom);

And in 4.20 it is this:


const float ContactOffset = FMath::Max(ComputeContactOffset(Geom), RestOffset + 1.f);

So the contact offset will never be able to go lower than 1 + whatever RestOffset is. I reverted this particular line of code with theone from 4.19 and that seemed to fix the problem.
[/]

Why did they change it to that? surely there had to be a good reason for it?
Edit: also, is there a way I revert this line of code without compiling from source?

> also, is there a way I revert this line of code without compiling from source?

Something I’m still working on but if somebody else works it out before me I’d love to know

Any further news on this?

Tried fiddling with absolutely everything I could possibly think of and still can’t solve this problem
Right now am just generating a big plane and resizing it to the level, solves the problem but really not in the way I want

Is it possible to just change that one thing in the source code and recompile it?
I’ve never tried compiling from source, so I’m not sure how it works when you only want to edit one thing and apply that as the version of the engine with the game

edit:
i gave up and spent like 3 days recompiling unreal from source & generating an installedbuild version to use
not sure it was the best tactic and wasted a tonne of time but at least i managed to change that one line of the source code haha
fixed the problem though even if it did take forever

I’ve been battling this for a long time. Lack of C++ experience had limited my ability to overcome it.

Recently I partnered with someone and they looked into it following this thread. We found the line listed above is currently in PhysicsGeometryPhysX.cpp rather than BodySetup.cpp

Replacing the line as indicated above seems to have fixed this issue when related to joined static meshes however it’s still an issue with landscapes.

God I’d love to pay a proper physics programmer, send him over to Epic Games and have him just ■■■■■■ fix their crazy physics. It really cant be that hard to sort this ■■■■ out. Ive never heard people using Unity complain about bad physics.

I have a project that was affected by this bug and I’ve managed to work around it by turning off the collision on my static meshes and replacing it with blocking volumes that I align perfectly to match the static meshes.

My ball rolls without any problem on the blocking volumes.

[]
Replacing the line as indicated above seems to have fixed this issue when related to joined static meshes however it’s still an issue with landscapes.
[/]

To fix this issue for the landscape, you will have to apply the same contact offset to the landscape collision shapes in ULandscapeHeightfieldCollisionComponent::OnCreatePhysicsState.

eg. HeightFieldShapeSync->setContactOffset(MaxContactOffset);

[=“, post:21, topic:37461”]

I can also confirm that the behavior has changed from 4.19 onwards and MaxContactOffset only has a limited impact. Looking at the source code it seems the problem comes from a line in FBodySetupShapeIterator::ForEachShape in BodySetup.cpp. In 4.19 it looked like this:


const float ContactOffset = ComputeContactOffset(Geom);

And in 4.20 it is this:


const float ContactOffset = FMath::Max(ComputeContactOffset(Geom), RestOffset + 1.f);

So the contact offset will never be able to go lower than 1 + whatever RestOffset is. I reverted this particular line of code with theone from 4.19 and that seemed to fix the problem.
[/]

and

[=“bybw, post:28, topic:37461”]

To fix this issue for the landscape, you will have to apply the same contact offset to the landscape collision shapes in ULandscapeHeightfieldCollisionComponent::OnCreatePhysicsState.

eg. HeightFieldShapeSync->setContactOffset(MaxContactOffset);

[/]

4.22.0 shows a whole different BodySetup.cpp file now. It looks almost completely rewritten. Thankyou for giving out this vital information to fix this long lasting Physics Issue. I thought I’d never get an answer to this. But still working on it… Right now I’m completely stuck on what to do and how to fix this for 4.22… I was hoping one of ya’ll can help look into that. Hope you guys can get back to me on this ASAP. This is crazy news to see we found some files that we can edit back to 4.19’s original state! :slight_smile:

I think part of what is causing this problem is actually penetration issue. I am not the most savvy guy, but based on my playing with this issue, I think the engine is “struggling” to come up with a proper way to calculate collision for the angular velocity of the ball. This issue happens considerably more frequently at high speeds and on flat surfaces and slopes using complex collision, with slopes causing even more trouble.

So my reasoning is that the increase in colliding faces multiple angles increases the odds of this happening.

Another fix for this is to enable ContactModification on BodyInstances.
In the UE4 source, BodyInstance.cpp/BuildBodyFilterData() set bUseContactModification = true;
(You can make this contingent on a UPROPERTY in PrimitiveComponents to make things more efficient, but the simplest fix is that one line.)
I presume this assumes that the returned modified normals need to be corrected, even though you haven’t actually changed them.
I haven’t dug into the PhysX source yet to see exactly what it does.

Steve McCrea
Tech Director
Armature

Also having this issue, will try the suggested solutions and report back.

I had some success with placing a constraint in the BP with the root declared and nothing in the second component (this then seems to default to world.
all constraints are set as free and I then put an linear motor speed zero on the z axis I set strength to 500
This effectively dampens the vertical motion… shame we have to do this tough

Paul G

[=“Biggumzzz, post:29, topic:37461”]

4.22.0 shows a whole different BodySetup.cpp file now. It looks almost completely rewritten. Thankyou for giving out this vital information to fix this long lasting Physics Issue. I thought I’d never get an answer to this. But still working on it… Right now I’m completely stuck on what to do and how to fix this for 4.22… I was hoping one of ya’ll can help look into that. Hope you guys can get back to me on this ASAP. This is crazy news to see we found some files that we can edit back to 4.19’s original state! :slight_smile:
[/]

Seems to have been rewritten in preparation for Chaos physics. That line of code can now be found in \Engine\Source\Runtime\Engine\Private\PhysicsEngine\PhysicsGeometryPhysX.cpp. Setting that line back to the 4.19 version in there has worked for me.

same issu and the contact max offset don’t change this problem ! pls help ^^

[=“Sly401, post:33, topic:37461”]

I had some success with placing a constraint in the BP with the root declared and nothing in the second component (this then seems to default to world.
all constraints are set as free and I then put an linear motor speed zero on the z axis I set strength to 500
This effectively dampens the vertical motion… shame we have to do this tough

Paul G
[/]

Was this succes for 4.22? If so, could you specify? I am trying to fix the issue without compiling from source. If you have a workaround I will be grateful.

[=“patrickolden, post:32, topic:37461”]

Also having this issue, will try the suggested solutions and report back.
[/]

Do you have any luck.

[=“GamesByHyper_Eric, post:36, topic:37461”]

Was this succes for 4.22? If so, could you specify? I am trying to fix the issue without compiling from source. If you have a workaround I will be grateful.
[/]

Sorry I have not yet tried 4.22

Paul G

Hey all,

I’ve put in a new bug for this as: Unreal Engine Issues and Bug Tracker (UE-74451)

Cheers!

Thanks , good news at last
Paul G

[=“Sly401, post:38, topic:37461”]

Sorry I have not yet tried 4.22

Paul G

[/]

K. That’s a pity. I have filed an official bug report. (as seen in the link posted by ) Hope it gets solved within the official build.