- Home /
Does a mesh collider animate?
I am trying to make it so that an enemy will damage a player when it touches the player. The enemy object has a character controller component. The enemy has a child object that has the skinned mesh renderer component, which we will call the model. I added a mesh collider to the model, and set it to be a trigger. I also added a script to the model to log when a hit occurs.
When the enemy swings it's arms to hit the player, nothing triggers. If I run directly in to the enemy, the trigger occurs. This sort of leads me to believe that perhaps the mesh collider is not animating along with the rest of the enemy, and perhaps I have not set it up correctly to do so.
Here is the enemy model, wish mesh collider.
Does the mesh collider animate along with the mesh renderer, or is there a way to make it do so? I need for when the ogre swings it's hand or its weapon at the player, for it to trigger a damage hit on the player. Any help would be appreciated. Thanks!
Answer by DESTRUKTORR · Sep 02, 2013 at 11:55 PM
To the best of my knowledge, no, and there's a very good reason for that: Performance! Mesh colliders are not very well suited for complex, moving meshes. I would suggest using hit-boxes for various parts of your unit, rather than a mesh collider, which is what pretty much everyone in the industry does XD.
i second that, try to avoid mesh colliders at all cost, for characters you could simple have several box colliders, hand collider, arm collider and so on. or even just one capsule cllider depending on what you need to do.
i personally mainly only use mesh colliders on terrain
Yep, pretty much. $$anonymous$$esh colliders should only be used with terrain, and trees, lol.
What if I want to get a particular triangle from a raycast? Am I S.O.L or is there a way to temporarily update a mesh collider with an mesh effected by animated bones and weights?
Finaly a nice answer, I was trying hard to discover how to animate the mesh collider, and now I understand why it is not possible. Thanks a lot.