Blend values in 3d for ground movement

Godot Version

4.5

Question

Hello, i just switched from using godot for 2d projects to 3d projects and i’m having some trouble figuring out how to properly blend between animations. right now i have my ground_movement blend value set to player x and z velocity although this seems only to work in one direction

What should the blend value be? so as to not mess up player movement animations when rotating the player?

	var actual_play_dir = Vector2() # some vector 2 i cant figure out

#ground movement
	anim_tree["parameters/Ground_movement/blend_position"] = actual_play_dir

It dosen’t seem to work with direction or velocity, the player moves exactly as they should. the issue is purely visual

This depends on so many things. What’s your camera view, for starters?

In what I find to be a typical setup for 3rd person over-the-shoulder, there’s an input direction and a basis rotation to orient input/visuals to the camera. In that case, you want to blend your forward/backward/strafe animations based on input direction, not the rotated velocity vector.

1 Like

Thank you, yes its third person and the issue is halfway there!
this seems to work well when the camera is facing in the direction the player is facing, but not when the camera is looking away from player direction

func update_anim_tree_blend_param() -> void: 
	var actual_play_dir = Vector2(
	Input.get_action_strength("sideways_right") - Input.get_action_strength("sideways_left"), # x
	Input.get_action_strength("forward") - Input.get_action_strength("backward") # z
	) * 100 # action strength is low

#ground movement
	anim_tree["parameters/Ground_movement/blend_position"] = actual_play_dir

e.g. if the camera is looking forward but the player is facing to the left of the camera and moving. the player animation “left_movement” will play (when its supposed to play forward running)

1 Like

What determines the global direction the player moves when the “move forward” action is used?

player direction is based on input relative to camera rotation. when pressing move_forward (w) and running the player will always run in the direction of the camera. When pressing move_backward (s) the player will run in the opposite direction to the direction the camera is facing

OK, so there’s a 3rd component… in addition to input direction and camera rotation, you have player facing (which you probably want to lerp for smooth turning). Some or all of those are going to be used to determine the animations to blend, depending on how many animations you have.

How would i define this because the direction the player moves relative to what direction the player is facing is ideally the value that I should be blending with

Before I say anything more, I recommend Lukky’s vid on this: https://www.youtube.com/watch?v=EP5AYllgHy8

From what you’re describing, I think you shouldn’t be using strafe anims at all. You’re always just turning toward the velocity and blending forward/back/turn anims. Does that make sense?