Godot Version
4.7 stable
Question
Hello, I have root motion project where i set character velocity from animation root motion (bone).
Problem arises when my statemachine changing states from one animation to another, the character velocity goes back to 0.0 instead of continuing from previous root velocity. I have blending enabled with values, i have tested without animation blending, same result.
What is odd is that in one case the velocity resets, in another case it works as expected.
Here is captured data that i printed out.
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
State: walk_start Velocity: 1.128 RM: (0.0, 0.0, 0.000376)
Changing state to: walk
State: walk Velocity: 0.000 RM: (0.0, 0.0, 0.0)
State: walk Velocity: 0.000 RM: (0.0, 0.0, 0.0)
State: walk Velocity: 0.000 RM: (0.0, 0.0, 0.0)
State: walk Velocity: 0.004 RM: (0.0, 0.0, 0.000001)
State: walk Velocity: 0.008 RM: (0.0, 0.0, 0.000003)
State: walk Velocity: 0.012 RM: (0.0, 0.0, 0.000004)
State: walk Velocity: 0.016 RM: (0.0, 0.0, 0.000005)
State: walk Velocity: 0.020 RM: (0.0, 0.0, 0.000007)
State: walk Velocity: 0.024 RM: (0.0, 0.0, 0.000008)
State: walk Velocity: 0.028 RM: (0.0, 0.0, 0.000009)
State: walk Velocity: 0.032 RM: (0.0, 0.0, 0.000011)
this happens in character process function.
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
var input_dir := Input.get_vector("k_left", "k_right", "k_forward", "k_backward")
direction = (player_camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
get_root_velocity(delta)
state_machine.physics_update(delta)
print("State: ", state_machine.current_state_name, " Velocity: %.3f" % velocity.length(), " RM: ",animation_player.get_root_motion_position())
Here is a demo video
In the mid playback i have slowed down engine to show that velocity resets.
And when that happens you get that nasty bump feel/look on your character which im trying to avoid.
Now the problem is when i go from Walk_start to Walking states/animations
The problem does not exist when going from walking to running states/animation - here velocity continues to increase .
Here is debug printout with that:
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: walk Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
Changing state to: run_16
State: run_16 Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: run_16 Velocity: 1.179 RM: (0.0, 0.0, 0.019654)
State: run_16 Velocity: 1.745 RM: (0.0, 0.0, 0.029086)
State: run_16 Velocity: 2.311 RM: (0.0, 0.0, 0.038518)
State: run_16 Velocity: 2.877 RM: (0.0, 0.0, 0.047951)
State: run_16 Velocity: 3.443 RM: (0.0, 0.0, 0.057383)
State: run_16 Velocity: 4.009 RM: (0.0, 0.0, 0.066814)
State: run_16 Velocity: 4.009 RM: (0.0, 0.0, 0.066815)
State: run_16 Velocity: 4.009 RM: (0.0, 0.0, 0.066815)
State: run_16 Velocity: 4.009 RM: (0.0, 0.0, 0.066815)
Velocity gets set the same way across all states with:
character.set_quaternion(character.get_quaternion() * character.animation_player.get_root_motion_rotation())
character.velocity = (character.animation_player.get_root_motion_rotation_accumulator().inverse() * character.get_quaternion()) * character.animation_player.get_root_motion_position() / _delta
Inside states physics update function.
Animations were done in blender with rigify rig by hand.
Root animations are all linear and loopable.
Not sure what else could be the problem.
PC is windows11 nvidia 4070s, 60hz monitor.
EDIT:
Forgot to mention how many frames are animations:
Walk = 32
Run = 16
Walk_start = 8






