- Home /
Discontinuity on mesh collider seams
I'm using a grid of meshes to represent a terrain. I've noticed some problems as convex and wheel colliders cross the border between two meshes.
A sphere rolling over the border will occasionally jump up even though in my test case the two meshes are completely flat. I've tried making the meshes overlap and I've tried bevelling them ever so slightly with overlap. I have smooth sphere collisions on. But nothing I do to the meshes can guarantee a smooth transition. As suggested in the answers changing the min penetration distance does help. Counter to what I expected bringing it to a near zero value reduces the jumping to imperceptible levels without introducing unwanted side effects.
However I haven't found a good solution for my problem with wheel colliders. The collider rolls over the border without any noticeable bump and provided it is not applying a longtitudinal or lateral force there is no problem. But if the tyre is cornering or accelerating it will suddenly slip and then grip as it travels over the border. This can affect the handling of the vehicle to a noticeable degree. Looking at in the debugger I can see that as the wheel crosses the border GetGroundHit will return a contact, the normal and position of the contact will be as expected and yet the force value will be zero. I suspect this tire load value of zero is probably also then zeroing the frictional forces for that frame. As with the sphere nothing I do to the mesh geometry seems to help. So save writing my own wheel collider code is there any way that I can write in the tyre load value I want used for the friction calculation? If I could do that I'd just use the value from the previous frame. Failing this I think I've reverse engineered the Unity tyre model to a sufficient degree in the past that I could perhaps apply my own direct force to the wheel for that one frame and get it close enough to reduce the problem.
None of this is particularly elegant. If anyone can suggest a way to fix the mesh transition itself I'd love to hear it.
Answer by le_duke · Mar 17, 2014 at 10:37 AM
I think that you need to play with the physsics engine parameters see : http://docs.unity3d.com/Documentation/Components/class-PhysicsManager.html
Increasing solver iteration count will increase physics precision.
You can also tweak the "min penetration for penality"
This solution is not very recommended as it can break other parts of how physics will work.
Answer by Raptosauru5 · Apr 06, 2020 at 10:04 PM
Rather than messing with physics, one solution that works well for me is to combine all terrain colliders into one big mesh collider. This works really good, but obviously it has it's own limitations, especially vertex count limit and therefore limiting the max size and also isn't probably very smart performancewise
Your answer
Follow this Question
Related Questions
Edit WheelCollider's Axis, not the Mesh 0 Answers
Having trouble getting a smooth collision with dynamic mesh collider 0 Answers
Wheel collider help 0 Answers
Internal collisions 1 Answer
Strange behaviour with wheel collider 0 Answers