- Home /
MeshCollider Failure at high velocities
Hello,
I've got a small problem here...
I have objects in my scene which are supposed to collide with terrain and explode (as in crashing and burning)...
The explosion bit is working fine... I'm having trouble with the collision detection though...
My setup turned out too big for a standard meshcollider applied to the terrain object... the terrain is procedural, and is updating quite a bit, and having it also have it's mesh collider proved too heavy for unity...
So I went for a different approach: Instead of applying the meshcollider to the entire terrain object, I'm keeping a small 2x2 quad mesh under it's target and having it mask the terrain, just as the terrain mesh does, but only for it's 9 vertices.
This works alright... the meshcollider moves along with the target object, and provides a 'ground' for it.
the trouble is that when the object is going really fast (it's a ship), collision will often go undetected, even though the object did hit the collision mesh... it just goes cleanly through...
I know this is a very common problem in physics simulations, and Unity does provide the Continuous detection mode just for that... I've got a little script here that will automatically switch the ship's rigidbody detection method based on it's velocity magnitude, so that at high speeds it uses continuous.
This used to work fine with the placeholder terrain (and it's terrainCollider)... but now that I've switched to a mesh, it will fail quite often.
This is a mission critical point in my game... the collisions CANNOT fail, even though you strike the ground at Mach 5...
So, does anyone have any thoughts about how to go abot fixing this?
Some more info about my setup:
The dynamic mesh collider is an independent game object controlled by script. It's positioned on FixedUpdate to always be directly below the target object, but at ground level. It will constantly update it's 2x2 quad mesh to mask the terrain. There is nothing else in the collider game object, apart from the meshcollider. it has no rigidbody, and not even a visual mesh.
The collision mode switching script is set to switch to continuous when the velocity magnitude exceeds 10.
As always, Thanks in advance!
Cheers
Just to follow up:
Apparently giving it a slightly larger mesh to work with made a significant difference... I gave it a 4x4 quad instead of the 2x2 I was using, and it's catching pretty much every collision now...
I still gotta stress test the thing to make sure nothing can go through it... if 4x4 quads is what it takes to have non-failing collisions, I'm pretty sure I can live with the slightly higher performance cost :)
Cheers
At high velocities $$anonymous$$eshColliders do also not work for me, even when I adjust the settings in the Physics $$anonymous$$anager. I always try to use primitive Colliders (Sphere, Box etc.) or Raycasts.
Your answer
Follow this Question
Related Questions
Implementing Meshless Deformation 0 Answers
MeshCollider Collision Table 2 Answers
How to setup collision with freshly generated mesh and prefabs 1 Answer
Rigidbody and convex mesh collider 1 Answer
Mesh Collider for Voxels 1 Answer