- Home /
Raycasting colliders moved by Mechanim animation?
Hello all,
I'm trying to create a system where I can damage specific limbs on a model (specifically by bullets, but not really relevant). I'm attempting to do this by attaching colliders to the bone structure, and then using RayCasts to determine if a limb was hit. However, any collider attached to a bone that has been moved by an animation (mechanim Animator) is out of sync with the physics engine -- the raycasts simply don't hit the colliders. Am I going about this wrong?
My model's are using Mechanim animations with colliders attached to the bone structure. The majority of the colliders were created using the Rag Doll wizard, with a few others added manually (hands and feet). Only the Rag Doll colliders have rigid bodies. All rigid bodies are set to kinematic through the checkbox in the editor. This does not change until the model dies, at which point I disable the Animator and enable kinematic on the Rigid Body so the model enters Rag Doll mode.
The issue is that any collider moved by the animation has its hit box out of sync with the physics engine. This applies to all colliders regardless of if it has a rigid body or not. How do I get the colliders which have been moved by an Animator to be hit by raycasts? Plenty of games have this functionality ... I don't think I'm trying to figure out anything too crazy here. I'm just clearly not attempting it in the right way within Unity ... I just don't know what I'm missing though.
Is there some way to get the colliders to be in sync with both the animation and the physics engine, or should I be attempting this functionality in a different way? This has been holding me up for almost a week now, so if anyone has a solution, I would really really appreciate it :).
Thanks again, Dale