Hi I have an animation thats transform position is animated to move from Vector3(-1,0,0) to Vector3(1,0,0).
I’m trying to figure how to get physics to work with this animation, for example, if while the object is moving from Vector3(-1,0,0) to Vector3(1,0,0) hits another object, I want the hit object to react as if it had been hit with force.
I’ve tried using ‘Animate Physics’ on the animator and using a Rigidbody on the object that’s being animated, and I’ve had no luck.
There are few things you need to check for:
- The object being hit also has Rigidbody and is not static.
- Uncheck ‘Apply Root Motion’ from the Animator component on the object that’s being animated.
- Update Mode is ‘Animate Physics’.
I found out why the physics weren’t working for me, the object that was being hit had a script that set the rigidbody’s velocity to:
new Vector3(Input.GetAxis(“Horizontal”, 0, Input.GetAxis(“Vertical”)).
So the velocity would always be that even if hit by an object, resulting in its receiving collision physics not working. @Julien.Lynge
You can disable the animator component when collides with objects, and then the rigidbody will work for you to apply physics to it .
to disable Animator :
Animator anim = gameObject.GetComponent(“Animator”);
anim.enabled=false;