# [SOLVED] Small ball bounces off crack in ground with zero width / slopes with sub 25* angle

Discussion in 'Physics' started by Skyclimber, Nov 25, 2017.

1. ### Skyclimber

Joined:
May 10, 2017
Posts:
2
Hi all. I'm working on an Oculus VR minigolf title and I've got everything working on the golfclub hitting the ball physics side of things. However, I've run into a couple of issues with how the ball interacts with static geometry.

Setup

Computer: i7, 32GB RAM, GTX 1070, Windows 10, 64-bit, Unity 2017.2.0f3

Since this is a VR title and I'm using the Oculus SDK to handle things like camera position and the Oculus Touch controllers, I've been working at a 1 Unit = 1 Meter scale. The ball is 0.04267 units in diameter, has 0.04593 mass, collisions consistently have a bounciness around 0.5, and uses the standard sphere collider. If ball velocity drops below 0.15, I stop the ball to combat the endless rolling problem caused by angular velocity not decreasing properly at small collider sizes.

Problems

1) I have two perfectly flush box or mesh colliders - zero height difference, zero gap, flat surface. Roll the ball towards the zero width gap and it bounces off of it consistently.

2) I have a couple of short hills - a mesh collider that starts with a level plane, slowly ramps up from horizontal to a max grade of 25*, ramps back to a level surface at the top of the hill, then repeats in reverse until it's back to the original level plane. If bounciness is at 0.5, it consistently bounces off backwards about halfway up the hill. If bounciness is at 0, it gets stuck at the top of the hill. There are plenty of real life mini golf courses with hills at even steeper grades than 25*, so definitely something I need to solve.

Things I've Tried

1) Bouncing off the infinitely small crack problem

I have tried changing the Default Contact Offset to something smaller. Default is 0.1 - Result: ball bounces off the crack. 0.01 - ball bounces off the crack most of the time. 0.001 and smaller - ball almost always goes over the crack, but now it goes right through walls. Not a useful setting.

I have tried increasing the default solver iterations. Default is 6. Increasing the value doesn't really help and just makes things increasingly laggy.

I decreased the Fixed Timestep from 0.02 to 0.01 and lower. Doesn't help and causes lag.

I have tried making sure that the golf ball object has a scale of 1 so that the rigidbody is at size 1 and only the collider and mesh are shrunk. No results.

I have tried changing the golfball to Interpolate and/or use Continuous or Continuous Dynamic Collision Detection. No results other than lots of lag.

2) Bouncing off a low angle slope / Getting stuck on it

As all of the above items aren't helpful, the only thing I've really tried here is adjusting the bounciness of the golf ball's collisions. As stated above, a bounciness of 0.5 makes the ball bounce off the hill after hitting a grade higher than about 12.5*. A bounciness of 0 just makes the ball get stuck at the top of the hill.

Conclusion

As far as I can tell I'm sort of out of options here for using a life size ball. I really don't want to have to try scaling everything up by... (calculates)... 23.435669 just to get a 1 unit diameter golf ball (supposedly the only reasonable solution to getting realistic ball physics according to this thread) because that just introduces a whole new pile of crazy in terms of physics and everything else.

Does anyone have any ideas/solutions that I haven't tried yet? Maybe a custom addon physics engine just for small spheres? This has been a problem throughout the entire lifecycle of Unity as far as I can tell and I don't think anyone has really solved it yet.

Thanks.

Last edited: Dec 30, 2017
2. ### BoogieD

Joined:
Jun 8, 2016
Posts:
228
I think the general problem is when colliding near an edge of a collider, the physics system will place the ball to the nearest outside edge which may end up being inside the adjacent collider.

3. ### Skyclimber

Joined:
May 10, 2017
Posts:
2
The problems are solved! I'll cover each item below. Hopefully folks will find this useful.

First off, increasing the scale of everything (size, gravity, friction, bounciness, etc.) does result in effectively the same physics behavior as normal 1-to-1 scale, but it introduces plenty of new issues with hand tracking and the like. On top of that, the zero width crack issue is only sort of fixed automatically, the slopes still cause bouncing, and spheres still roll forever. In other words, it's not worth it so stick to real world scaling...

After doing additional research into the topic, I've figured out why the ball bounces off of zero width cracks. Keep in mind that the sphere effectively has only one incredibly small contact point with each surface and Unity handles collisions sequentially instead of simultaneously. In the case of the zero width crack, the ball first reaches the end of the box and drops downwards slightly. It will then collide with the side of the next box instead of the top. At this point, the sphere behaves identically to any sphere hitting a wall and bounces off. There's not really anything that can be done about this issue other than designing your world to not have these cracks in the first place or put the cracks right up against walls the ball would bounce off of anyways.

As for mesh collider slopes, the solution is to ramp up the slope angle in smaller increments. I've found that increasing the slope in increments of 5* works fantastically.