- Home /
How can I use Animate Physics in a project?
I've been trying to figure out what the Animate Physics check box does on the Animator controller, and I've had absolutely no luck. I do know that it uses kinematic rigidbodies to affect other objects, but I don't understand how.
As an example, I was under the impression that I could use Animate Physics to carry a player on a moving platform, but it doesn't seem to work properly. The player just keeps falling off.
Could someone enlighten me as to how the Animate Physics setting truly works and what it can be used for?
I had an arm with a sword parented to the hand bone in blender.. i imported it and put a box collider on the sword.. it worked for one kill.. then quit interacting with my monsters colliders.. i couldn't figure it out after a lot of hassle.. I tried the animate physics.. it didn't seem to solve my problem.. so i created a spawn point and shot invisible projectiles ins$$anonymous$$d while my sword swing animation played.. its ok now.. but I wish i could have gotten that box collider to work..
Your problem, I imagine, is related to OnCollisionEnter callback and the fact that there is always something in contact with the collider, namely the player's collider.
You can test this theory by adding
function OnCollisionExit()
{
Debug.Log("EXITED");
}
and seeing if the debug message ever fires.
Answer by Kavorka · Feb 12, 2014 at 08:08 PM
Hello Animate physics only changes when the animator updates. If not set, animator updates after Update and before LateUpdate. If set, animator updates with FixedUpdate. It is not a magic button that turns a character into this.
how did you create these effects which seem to combine rootmotion and forces somehow?
What do you mean the animator updates after Update and before LateUpdate, updates what? I track the transform of a bone where it is animated and I can see in fixedUpdate, Update and LateUpdate it the transform position changes. Btw the animator update mode is on "Normal" but even if I set it to Animate Physics it still behaves the same
Well, have a look at the event execution order, especially the flowchart at the end. By default the animation update is executed after all Update methods have been called and before the LateUpdates are called. "animation update" means that the animation time is increased and the bone positions / rotations are updated. That means if you "read" a bone position in Update you actually read the position from the last frame. Also it means that you can't overwrite a bone rotation / position in Update but you can in LateUpdate.
When Animate Physics is used the animation system is updated from inside the physics loop which actually happens before Update (see the flow chart).
When you said
it still behaves the same
what behaviour are you referring to? Your question is a bit confusing.
What i mean is that I have a simple script that outputs a bone's transform changes, I have it in fixedupdate, update and lateupdate. So what I should see is only changes between the output in update and lateupdate since it should be updating in between those two functions but I don't see that. When I see the output (from Debug.Log statements) the transforms are changing within fixedupdate, changing between fixdedupdate and update and changing between update and lateupdate. This behaviour happens regardless of the update mode, if I keep it "Normal" or "Animate Physics" on the animator
Answer by cician · Jan 03, 2014 at 05:18 PM
On each element of animated object you need attached a collider and a rigidbody. Rigid bodies should be set as kinematic. NB: the animate physics option only works for 3D physics (help, vote! http://feedback.unity3d.com/suggestions/animate-physics-2d).
The rigidbodies animated this way properly apply forces and friction on external objects. Without it the colliders just change the position. It may seem OK at first look because other rigidbodies get pushed out by the physics engine, but the result is incorrect.
Your answer
Follow this Question
Related Questions
Is there a way how to use both Animate Physics and Unscaled Time update modes in animator ? 0 Answers
2D: Animate physics doesn't work with Animator? 0 Answers
In Profiler: What is "Animator.SendTransformChanged" 0 Answers
Animator not playing onCollisionEnter. 3 Answers
Interaction with object after animation 0 Answers