how to apply physics to an animated object

Hi all,

I have animated a target object to move with the animation tab, 3 key frames so the object goes side to side with a loop.

The issue i’m having is that on the first few targets that don’t move the physics knock the target over when hit and destroy in 3 seconds but on the same targets with the animation applied the hit still registers and destroys after 3 seconds but the target does not fall over and just keeps going form side to side for the 3 second period.

How would I make it so that when the bullet is hit that the animation is to cease and rigidbody.AddForce(Vector3(0,0,3)) to apply.

thank you,

Ben

You cannot perform direct procedural movement on an object that is being animated. The animation is overwriting the physics you are attempting to perform. The way to get around this is to have your animated object contained in an empty parent object, and apply your physics forces to that parent object.

To stop your object from animating it should be as simple as calling animation.stop() on the object that is animating.

Edit:
Also please note, this gets tricky if you have a hierarchy of animated objects acting as a skeleton, if you break the hierarchy chain by inserting an empty object into it, the physics will indeed work, but the animation will likely break.