Godot Version
4.5
Question
Hey, I’m new to 3d projects and i’m having some trouble figuring out how to handle blendspace2d blend value for basic movement. Player locomotion is handled globally and i’m not sure how to translate that to a “local” value.
Right now when the player velocity is moving in a positive direction on the x axis, the player animation is animated as moving forward. Although if the player turns 180 degrees the player “should” still move forward, but instead the walking backwards animation is played. this happens because the velocity is negative on the x axis.
How would i fix this ?
I thought about rotating the velocity by the player rotation but i can’t quite get it working. I tried:
var loc_vel = velocity.dot(global_transform.basis.z).normalized() var loc_vel = velocity.rotated(Vector3(0,1,0),visual_model.rotation.y).normalized()
but neither seemed to work
I need to blend between some “local” value that isnt affected by the global axis. Any and all help is appreciated
func update_anim_tree_blend_param() -> void:
var input_dir = Input.get_vector("sideways_right","sideways_left","backward","forward")
var actual_dir = ??????
#ground movement
anim_tree["parameters/Ground_movement/blend_position"] = ?????????