I’ve recently begun working on a mini golf game, and my plan for it was to use a large portion of Unity’s physics to handle the golf ball, and for simple/flat holes this works fine. However, a major issue comes in when I need to make more complex holes like this one: http://i.imgur.com/2yYHyNY.png
My intent was to use mesh colliders for the ground, since I need the accuracy. However, when using mesh colliders, the ball tends to skip and hop as it rolls or slides across the ground. This is a very big problem and I was wondering if anybody had any ideas as to how I could fix this (short of writing my own physics or something)?
If you dont want to write any code, than your only option might be to increase the amount of polygons your complex holes have so that you can smooth them out. If you used blender, put a sub division modifier on the mesh and apply it on export.
Thanks for the reply, but I’ve actually tried that already, and that doesn’t fix the problem.
Something else I have noticed is that the ball doesn’t jump at all when rolling across a more flat mesh collider like this: Imgur: The magic of the Internet
Im still rather new to unity myself. This option has been known to fix physics anomolies like jittering, but Im not exactly sure just how bad it can affect a game’s performance since it can eat up more processing power.
Edit > Project settings > time and set Fixed timestep to a slightly lower number like .001 or lower. This allows more physics calculations to be performed.
Well, its hard to tell what is going on and what you mean by bouncing and skipping. If you mean the ball is not rolling completely smoothly, than I still think it might just be your terrain is just not smooth enough. If you can tell the ground has polygons, then the ball will bounce or move weird when it hits a flat polygon.
The problem seems to be Continous dynamic being enabled. I think I read somewhere that the way continuous dynamic prevents from going inside things is by just completely stopping. When your ball goes way to fast, it probably just stops in the direction its going, but then then the physics pushes it way up in the air.
Turn your rigidbody to discrete and you will notice the problem stops, but now if you go way to fast you will go through things.
The problem can still happen with discrete, but its probably a lot less.
Weird, I still have the problem even when using discrete… Are your physics settings different than the ones I posted earlier? My fixed timestep is 0.01 as well.
No, the more I look at it, the more I think I can still see the little jumps. It was just the initial force at the start that removing continuous dynamic fixed. The force was like 2750, and I had to do some code changing since you didn’t give everything and had some missing references.
I am having a similar problem. Whether it’s discrete or continuous dynamic, my cars bounce randomly. Maybe it’s related to the size of the mesh collider?
Setting it to descrete or continuous collision made no difference, I only first thought it did, but was mistaken. Unfortunately, from looking at my conversation with him in my inbox, we found no fix and he said he might try terrain colliders.
This problem was actually fixed for the most part in some update a while back (I forget which one).
However, there is one important thing related to this problem that may not be apparent at first: Mesh colliders that use meshes with split edges or “flat” shading will cause other colliders to bounce when they roll or slide over edges.
The mesh in front has no split edges and so colliders will (most likely) have no problems when rolling or sliding over it. You can tell that it has no split edges because of how smooth it looks.
The mesh in the back however does have split edges, and so colliders may bounce when they roll over this meshes edges. You can tell that it has split edges because of the noticeable edges between each rectangle.
With completely flat surfaces it’s basically impossible to tell whether a mesh has split edges or not unfortunately. But if you are exporting from Blender you need to make sure your collision meshes are set to “Smooth” shading, otherwise their edges will be split and you will have bouncing problems.
Are you sure that changing the shading to smooth does anything (for collision)? You are saying “The mesh in front has no split edges…”, but isnt that wrong? It still has all the split edges, the only change is the vertices normals.
This video explains it well.
From my quick tests, it doesnt seem like the smooth shading is changing the actual normals returns by OnCollisionStay contact normals or raycast / spherecast.
Here is my test video with the OnCollisionStay contact normals, both smooth and non smooth seem to return the exact same results.
All in all, smooth shading is just for visuals as far as I know.
Do you have any proving examples of smooth shading doing something, or is it maybe just the update that fixed everything? I am really curious since if this smooth shading thing actually does something, then it should very much be documented.