Rotation not happening as expected

Godot Version

v4.3.stable.steam [77dcf97d8]

Question

This is probably the most baffling error I’ve come across. Potentially ever. I’m trying to rotate a Marker2D, and while all other rotations are working, the 180 degree rotation doesn’t? Instead, it places it where the opposite 90 degree rotation is (-180 = 90, 180 = -90). All the other bits of code in its section work just fine, it’s just this one bit that’s weirdly broken somehow.

Relevant code:

func player_movement(delta):
	if Input.is_action_pressed("move_right"):
		current_direction = "right"
		$Direction.set_rotation(-90)
		play_animation(1)
		velocity.x = SPEED
		velocity.y = 0
	elif Input.is_action_pressed("move_left"):
		current_direction = "left"
		$Direction.set_rotation(90)
		play_animation(1)
		velocity.x = -SPEED
		velocity.y = 0
	elif Input.is_action_pressed("move_down"):
		current_direction = "down"
		$Direction.set_rotation(0)
		play_animation(1)
		velocity.x = 0
		velocity.y = SPEED
	elif Input.is_action_pressed("move_up"):
		current_direction = "up"
		$Direction.set_rotation(-180) # Broken one
		play_animation(1)
		velocity.x = 0
		velocity.y = -SPEED

Thank you for any help or insight you can provide, it’s much appreciated!

set_rotation uses radians not degrees.
Use deg_to_rad() to convert.
Or use set_rotation_degrees()

Thank you, I’m glad it was so simple!

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