Hi all.
In a shooter game, you’ll want your bullets to collide per-poly, so in Unity terms, you’ll have to use a mesh collider. However, You also don’t want all the physics to be per-poly, due to the effect on performance. The question is, can this be achieved with unity? Using per-poly for raycasts while using simpler shapes (e.g. boxes) for movement and collision?
Absolutely. Using layers and the collision matrix to select which layers collide with each other.
In the layer settings create one layer named “Mesh” (As an example only, name it what you want).
Uncheck all the toggle buttons in the Collision Matrix that has to do with the “Mesh” layer (Both the horizontal buttons and vertical buttons). This ensures that no physics calculations will be done on the “Mesh” layer.
Add the mesh collider and set the GameObject to be in the “Mesh” layer.
Add the generic collider to a parent GameObject and set the layer to “Default”.
When you raycast to shoot now, only raycast against the Mesh layer with:
Physics.RayCast(ray, out hit, distance, layerMask);