Rotation Issues in Player Controller

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I want to rotate my car controller (CharacterBody3D) based on the input. This works with all directions beside “up”. In this case, I have problems rotating the car slighty left
Reason: up is 0 degrees. up-left is -270 degrees so it makes a spin. Has anybody an idea to solve this?

Script:

func rotate_point(delta) -> void:
	var siggn = 1
	if last_direction.cross(Vector3(0, 0, -1)).y < 0:
		siggn = -1
        rotation.y = lerp(rotation.y, last_direction.angle_to(Vector3(0,0,1)) * siggn, 
        turn_speed * delta)

Thanks for any help!

Try lerp_angle rather than lerp, it should account for angles wrapping around.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.