Godot Version
4.4.1.stable.mono
Question
func process_physics(delta: float) -> State:
var raw_direction = Input.get_vector("mov_left", "mov_right", "mov_up", "mov_down").normalized()
var mov_direction = Vector3(raw_direction.x, 0.0, raw_direction.y).rotated(Vector3.UP, parent.cam_anchor_y.rotation.y)
var face_direction: Basis
if mov_direction != Vector3.ZERO:
face_direction = Basis.looking_at(mov_direction)
parent.velocity = mov_direction * speed
parent.char_anchor.basis = parent.char_anchor.basis.slerp(face_direction, 0.2)
parent.move_and_slide()
return null
This is my current code for moving my player character during their “walking” state, currently this works perfectly fine for movement, but the interpolation I am using sometimes causes the character to rotate up slightly if the movement direction changes quickly. For obvious reasons I would like to make it so the character only rotates on the y axis; what would be the simplest change I could make to achieve this while keeping rotation interpolation? maybe there is another form of interpolation I could use? I am still very new to GDscript.