Large meshes and custom collision solutions

I’m working on a level that makes extensive use of large environment assets like cliffs, rocks, etc. Some of the largest pieces are approx. 40x50 meters. I’ve made custom collision meshes for each large piece that consist of an absolute minimum number of triangles but the collisions are spotty at best – my projectiles and moving objects (characters/vehicles) either collide or don’t with the object, often ending up inside the large meshes.

I will probably end up with a raycast addition for some of the projectiles but I can’t figure how to implement functioning collision on the large rock pieces even when colliding with slow moving objects.

Does the number of triangles affect the function of a collision mesh? Do more triangles in a collision mesh help make collision more accurate even if it’s more expensive for the engine?

Are the primitive colliders (non-custom) in Unity that much more functional than custom colliders? If so, is it feasible to build a bunch of dummy obejcts and use cube/sphere/capsule/colliders in the level? Any way to use colliders with out attaching them to objects?

Thanks in advance.

I’ve run into a problem like what you describe, in fact, it’s been an issue for as long as I can remember. There’s an old script in the wiki that uses raycasting to prevent fast objects from passing through colliders, but I don’t recall having much luck with it. What I found was that the moving object’s velocity and relative size were the determining factors in whether the object “hit” or passed through. I’ve yet to find a good solution to this though and have typically had to use ugly hacks to work around it.

Thanks, BK. I spent the last 4 hours testing this further.

I’ve concluded that colliders set to be convex are far more effective than mesh colliders that aren’t. Makes sense and most game engines that I use (UDK, Source) still make best use of convex collider meshes. They also offer tools to make multiple convex collision meshes to be used as colliders for a single game mesh. Doing this manually for Unity is going to be time consuming. Would be great to have some tools to aid in this.

Two questions at this point:

  1. Are there any performance issues with using a custom compound collision mesh collision solution for an entire environment? It will require hundreds if not thousands of convex mesh pieces.

  2. If I prefab each environment piece (cliff pieces, etc) will that aid in performance?

Thanks!

Still no answer to my above questions but I wanted to update with my current solution:

I’m making several low-res (12-200 triangles) convex hull meshes for use as collision meshes for each large game mesh. I’m exporting them from my 3D app as children of the display mesh. In Unity I have them set as mesh colliders with convex ON and mesh renderer OFF, displaying only the intended art mesh.

The difference in collision accuracy with using only convex collision meshes is tremendous. Even if the mesh is convex but the convex flag is not on the collision will fail.

There are some scripts for Max around to aid in the creation of convex hulls.