Godot Version
4.4.1
Question
When I try to rotate a cube for 90°, it generally works, but as soon as the next_rotation is 270°, the cube keeps spinning forever and doesn't reach the 270° degrees.
extends MeshInstance3D # This is a simple cube mesh in the game.
var next_rotation: float
func _unhandled_key_input(event: InputEvent) → void:
if Input.is_action_pressed(“rotate”):
next_rotation += 90.0
if next_rotation == 360.0:
next_rotation = 0.0
print(next_rotation)
func _process(delta: float) → void:
global_rotation_degrees.y = lerp(global_rotation_degrees.y, next_rotation, 0.1)