Mesh Collider for avatar not working

Working in HDRP with Unity2019.2.1f1
I need projectiles to collide (OnTriggerEnter) with an avatar in my scene so I’ve added a Mesh Collider (see attached for Editor settings).
I’ve properly linked the Body mesh to the Mesh slot but on playback there are 2 issues

1- The mesh Collider is offset from the skinned mesh
and
2- The Mesh Collider is not being animated by the skinned mesh

Can anyone tell me what I am doing wrong?


I don’t think Unity can animate colliders like that. You’re not doing it wrong, the engine just doesn’t allow it as far as I know. The best “solution” is probably to build the collider from several simpler ones that you can move around individually with the bones of your rig. In many games the character colliders consist merely of a few geometric primitives rather than a detailed mesh.

If you do need 100% accurate collision detection, you can reassign the deformed mesh every frame. You can get the deformed mesh using SkinnedMeshRenderer.BakeMesh and you can assign the result to MeshCollider.sharedMesh. This is probably very slow though.

I have seen games with animated terrain collider meshes and they worked quite well, it all comes down to how well you optimize things. You would just have to animate your collider mesh along with your player mesh. Or, you could put a rigid body collider on the avatar (which most have) and use the raycast command to detect projectile hits on the collider.