How to use root motion to make a 3D character move in Godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hanate


I’m trying to use root motion with a 3D model animation, but I don’t manage to make it work to move my character. I don’t know what I’m doing wrong.

What I have done so far :

  1. I have an AnimationPlayer with a “running” animation. I have an AnimationTree that enables this running animation by default. The animation is played, my model is moving in the preview. The animation is cycling

  2. I configured the AnimationTree root motion track to be the root bone. Now, my model is running “in place”, not moving anymore (what is expected). When I add a RootMotionView in the scene, the model is “moving” against the RootMotionView, as expected.

  3. I add a script to my scene (which is a Character3D), and, in the _process function, I try to get the root motion position to update my character position, as explained in the AnimationTree documentation.

Here is my problem : $AnimationTree.get_root_motion_position() always returns me a Vector3(0, 0, 0).

The documentation states

If root_motion_track is not a path to a track of type Animation.TYPE_POSITION_3D, returns Vector3(0, 0, 0).

My root_motion_track is configured to be my root bone. I checked it as runtime using $AnimationTree.get_root_motion_track(), and it points toward my root bone. I don’t know how to check the “type” of the root bone however.

I guess my root motion track is configured correctly, because it works as intended in the scene view. Do you have any idea of what am I doing wrong ?


:bust_in_silhouette: Reply From: Hanate

I made it work.

I don’t really know where I messed up, but I rewrote it from scratch and it worked.