3
\$\begingroup\$

I am a newbie trying to learn basics of Unity3D (5) before starting to do the real thing. Even though I tagged it as Unity3D, the logic should be the same for every kind of game engine. So I will be glad if you share your experience even though you do not use Unity.

Assume that you are importing the "Lamp" character (fbx) of Pixar. (Jumping, moving forward by little jumps, etc..)

OR

Assume that you are basicly importing a humanoid model with animations from Unity Asset Store. (I know that they generally include controllers too, assume that there are no controllers)

In unity, I want to make the character jump so I use jump animation. But I really want to make it jump. Also when I move it forward I really want it to move forward by appying a force or setting it's velocity. These will probably will not match the animation and even if they match, my own physics manipulations will be mixed with the animation's transformations. Even if I put the animation/object into another GameObject, it changes the position and/or rotation of the parent gameobject. So, animation changes those values and I also change them myself... The result will be the combination of all which is very hard -if not impossible- to sync or calculate.

The same thing is valid for almost every animation including Jumping. For example, the animation jumps and I also make the object jump.. It will create a double jump.. If I only let animation does that, I won't be able to control how it really behaves and If I make the animation look like it's crouching (actually jumping, but transformed to 0,0 in every frame, so in Unity changing the vertical position will fix it...) it will be hard to sync too.

What am I missing here? What is the guideline here?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The Unity Mecanim animation engine uses the concept of Root Motion to drive it's animations (assuming the animation contains the appropriate data).

If you'd rather move/rotate the gameObject yourself then you can disable an animation's root motion in each individual animation during the asset import process in the 'Animation' tab. That would allow you to then drive the animations transforms using a script etc.

I believe what you're looking for is in the following reference material : http://docs.unity3d.com/Manual/ScriptingRootMotion.html

Basically, if you override the 'void OnAnimatorMove()' method in a MonoBehaviour script which is attached to your animated gameObject, then the Animator component will recognise that the gameObject's animations are to be "Handled By Script".

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the information and for your time. Are you aware of the most accepted way to do it? Should we almost always override or not? \$\endgroup\$
    – frankish
    Apr 14, 2015 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .