# Rolling ball jumps on flat surface

**URL:** <https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461>\
**Category:** World Creation\
**Tags:** unreal-engine, Physics\
**Created:** [August 3, 2015, 2:56pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461 "2015-08-03T14:56:14Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_adc3f730](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_adc3f730](https://forums.unrealengine.com/u/anonymous_user_adc3f730)\
**Post date:** [December 22, 2018, 3:41pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/22 "2018-12-22T15:41:19Z")

</div>

[=“, 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:

```auto

const float ContactOffset = ComputeContactOffset(Geom);

```

And in 4.20 it is this:

```auto

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c908d868](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c908d868](https://forums.unrealengine.com/u/anonymous_user_c908d868)\
**Post date:** [January 7, 2019, 4:59pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/23 "2019-01-07T16:59:29Z")

</div>

\> 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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1aa5ec3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1aa5ec3c](https://forums.unrealengine.com/u/anonymous_user_1aa5ec3c)\
**Post date:** [January 13, 2019, 12:59am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/24 "2019-01-13T00:59:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e6f2a6ec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e6f2a6ec](https://forums.unrealengine.com/u/anonymous_user_e6f2a6ec)\
**Post date:** [February 3, 2019, 1:57pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/25 "2019-02-03T13:57:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Adeptus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Adeptus](https://forums.unrealengine.com/u/Adeptus)\
**Post date:** [February 5, 2019, 10:00am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/26 "2019-02-05T10:00:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TMWNN\_35](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TMWNN\_35](https://forums.unrealengine.com/u/TMWNN_35)\
**Post date:** [February 20, 2019, 12:41am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/27 "2019-02-20T00:41:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bybw](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bybw](https://forums.unrealengine.com/u/bybw)\
**Post date:** [February 27, 2019, 10:21pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/28 "2019-02-27T22:21:48Z")

</div>

[]  
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);

---

<div class="post-metadata">

**Author:** ![Biggumzzz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Biggumzzz](https://forums.unrealengine.com/u/Biggumzzz)\
**Post date:** [March 11, 2019, 12:54am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/29 "2019-03-11T00:54:16Z")

</div>

[=“, 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:

```auto

const float ContactOffset = ComputeContactOffset(Geom);

```

And in 4.20 it is this:

```auto

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! 🙂

---

<div class="post-metadata">

**Author:** ![Cloel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cloel](https://forums.unrealengine.com/u/Cloel)\
**Post date:** [March 26, 2019, 10:27pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/30 "2019-03-26T22:27:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve\_McCrea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_McCrea](https://forums.unrealengine.com/u/Steve_McCrea)\
**Post date:** [April 3, 2019, 3:39pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/31 "2019-04-03T15:39:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patrickolden](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@patrickolden](https://forums.unrealengine.com/u/patrickolden)\
**Post date:** [April 10, 2019, 5:06pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/32 "2019-04-10T17:06:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sly401](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sly401](https://forums.unrealengine.com/u/Sly401)\
**Post date:** [April 11, 2019, 12:09am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/33 "2019-04-11T00:09:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lambomang](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lambomang](https://forums.unrealengine.com/u/lambomang)\
**Post date:** [April 16, 2019, 9:56am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/34 "2019-04-16T09:56:29Z")

</div>

[=“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! 🙂  
[/]

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.

---

<div class="post-metadata">

**Author:** ![Hugopeo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hugopeo](https://forums.unrealengine.com/u/Hugopeo)\
**Post date:** [April 26, 2019, 11:06pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/35 "2019-04-26T23:06:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GamesByHyper\_Eric](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gamesbyhyper_eric/32/709237_2.png) [@GamesByHyper\_Eric](https://forums.unrealengine.com/u/GamesByHyper_Eric)\
**Post date:** [May 7, 2019, 9:56pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/36 "2019-05-07T21:56:38Z")

</div>

[=“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.

---

<div class="post-metadata">

**Author:** ![GamesByHyper\_Eric](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gamesbyhyper_eric/32/709237_2.png) [@GamesByHyper\_Eric](https://forums.unrealengine.com/u/GamesByHyper_Eric)\
**Post date:** [May 7, 2019, 9:57pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/37 "2019-05-07T21:57:40Z")

</div>

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

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

Do you have any luck.

---

<div class="post-metadata">

**Author:** ![Sly401](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sly401](https://forums.unrealengine.com/u/Sly401)\
**Post date:** [May 8, 2019, 8:59am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/38 "2019-05-08T08:59:17Z")

</div>

[=“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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_942e8e52](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_942e8e52](https://forums.unrealengine.com/u/anonymous_user_942e8e52)\
**Post date:** [May 10, 2019, 5:05pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/39 "2019-05-10T17:05:21Z")

</div>

Hey all,

I’ve put in a new bug for this as: [Unreal Engine Issues and Bug Tracker (UE-74451)](http://issues.unrealengine.com/issue/UE-74451)

Cheers!

---

<div class="post-metadata">

**Author:** ![Sly401](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sly401](https://forums.unrealengine.com/u/Sly401)\
**Post date:** [May 11, 2019, 8:19am UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/40 "2019-05-11T08:19:36Z")

</div>

Thanks , good news at last  
Paul G

---

<div class="post-metadata">

**Author:** ![GamesByHyper\_Eric](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gamesbyhyper_eric/32/709237_2.png) [@GamesByHyper\_Eric](https://forums.unrealengine.com/u/GamesByHyper_Eric)\
**Post date:** [May 13, 2019, 6:49pm UTC](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461/42 "2019-05-13T18:49:59Z")

</div>

[=“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](https://issues.unrealengine.com/issue/UE-74451) posted by ) Hope it gets solved within the official build.

[Previous page](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461.md?page=1)

[Next page](https://forums.unrealengine.com/t/rolling-ball-jumps-on-flat-surface/37461.md?page=3)
