0 votes

In game development we oftens use root motion to make animation movement precisely.
But in godot Animation Tree docs did mention about how to retrieve root motion but don't give a real example of how to use it. Do you ever experience this problem? Can you give my an usage example?

in Engine by (67 points)

1 Answer

+1 vote

You can apply the root motion to any object, it depends what you want to achive, you can look at the TPS Demo, they have a kinematic character and an instanced animated scene, they get the motion from the animated scene and then move the kinematic character with the velocity:

orientation *= root_motion
var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity += gravity * delta
velocity = move_and_slide(velocity, Vector3.UP)

orientation.origin = Vector3() # Clear accumulated root motion displacement (was applied to speed).
orientation = orientation.orthonormalized() # Orthonormalize orientation.

I've made a few videos about root motion and the state machine here and they are based on the TPS Demo controller.

I also made an Infinite scroller where the player doesn't move and the root motion is applied to the rooms (that project is made in C#).

by (994 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.