Hi, I am trying to implement a root motion system in my game but it’s currently not working
Expected Output:
Current output:
As you can see, the animation is being played. However, the character itself isn’t moving
Below is how I implemented this system. I would be more than delighted if any kind soul may take some time to go through it and point out any problems with how I have implemented it
For future questions, please just copy/paste your code and surround it with 3 tick marks (key to the left of 1 on most keyboards) to format it:
```
func _ready():
print(“foo”)
```
Becomes
func _ready():
print("foo")
Screenshots of code are not easy to work with.
To your question:
What does the print(self.velocity) show? Also, why divide by delta when setting a velocity? delta is already used internally in move_and_slide() with velocity to determine how the position should change. (Also, you’re in _process(delta), so you can just use delta instead of self.get_process_delta_time()).
I don’t know what your StateMachine node looks like, so I have no idea what get_root_motion_position is supposed to do. I think you should either provide more code, or add more print statements for each value to see which one is not doing what you think it should do.
I was under the impression that as the movement is calculated overtime, I would need to divide it by delta. Does that mean I only need to divide a value by delta if that value isn’t being used by move_and_slide()?
You’re in _process(delta), so you can just use delta instead of self.get_process_delta_time())
I saw a post online that stated every process has their own delta value and for animations there’s a special delta value that they use and the way to access that value is through that function
I had a very similar issue and for me the cause was that Godot was not recognizing the root properly. The fix was to go into import settings for the model → add a bone map under retarget → add a skeleton profile → go to the root at the bottom of the feet of the skeleton profile and set the root bone as that root. That was the root cause, no pun intended. As soon as the correclty flagged root bone is translated in an animation track, it was displayed in place now and the motion was only visible with a rootmotionview node in the scene, when you are looking at the animations executed by the animationtree. But you also have to make sure the root bone is actually translated in the animation track as well.