3
\$\begingroup\$

so I'm starting with Unity , I followed the john lemon tutorial , and I wanted to apply what I learn on a model on my own coming from blender. Everythings works , animation , rotation , but not translation . For some reasons my character doesn't move at all . It might have to do something with root motion since I have apply root motion in grey with written just after "handled by script" . Not sure what to do .. I found something about character in place, I think I'm in this case but I'm not sure how to use it in my script .. https://docs.unity3d.com/Manual/ScriptingRootMotion.html

If you ask I'll give you my project .

EDIT :

ok so I made some advances :

 void OnAnimatorMove()
{
 m_Rigidbody.MovePosition(m_Rigidbody.position + m_Movement * m_Animator.deltaPosition.magnitude * 10000);
 m_Rigidbody.MoveRotation(m_Rotation);
 Debug.Log("m_Animator.deltaPosition.magnitude: " + m_Animator.deltaPosition.magnitude);
}

m_Animator.deltaPosition.magnitude is actually always equal to 0 , explaining why my charachter doesn't translate but why is it always equal to zero ?

DMGregory
140k23 gold badges256 silver badges392 bronze badges
asked Jun 10, 2019 at 10:06
\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

I have the same problem, I started solving it by removing the last part:

m_Animator.deltaPosition.magnitude to some other float that i want and called it speed meaning my OnAnimatorMove is looking like this

//move the position

m_Rigidbody.MovePosition(m_Rigidbody.position + m_Movement * 0.05f);

you can either change the last float to a public variable for you'r convenient

Another sulotion that i found relevant to my case that in my animation setting of the walk animation i activated the bake into pos option for the x,z,y transforms once i disabled it that worked just fine with the same code but i neede to add a speed variable and multiply by it because it was too slow

Boneco Sinforoso
6811 gold badge20 silver badges47 bronze badges
answered Mar 29, 2020 at 19:12
\$\endgroup\$
3
\$\begingroup\$

Animator.deltaPosition Gets the avatar delta position for the last evaluated frame.

Animator.applyRootMotion must be enabled for deltaPosition to be calculated.

https://docs.unity3d.com/ScriptReference/Animator-deltaPosition.html

You have to enable your animator's applyRootMotion. if you don't enable this option or your avatar doesn't have a delta position (not changing position), then Animator.deltaPosition returns 0.

More about applyRootMotion: https://docs.unity3d.com/ScriptReference/Animator-applyRootMotion.html

answered Jun 12, 2019 at 11:57
\$\endgroup\$
1
\$\begingroup\$

I think I found a solution.

I ran into the same problem, but I solved it in the following way

  1. animation correction I used my own models and animations, but I wasn't moving them forward despite the walking animation. (It was stamping feet on the spot.) This has been modified to move forward.

  2. select the root node Armature/Hips were assigned to the Inspector/Rig/Root node of the model. Initially I was simply going to Armature, but then I realized that the root of the animation was Hips.

After fixing the above two points, the problem was solved.

I hope this helps those who still refer to this thread.

Sorry for the poor English, thank you.

answered Nov 10, 2020 at 7:46
\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.