How can I rotate 3d Object on it's Y axis smootly?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Flipp3rix

Hi guys… i’m trying to rotate a KinematicBody on it’s Y axis and for now i have this current setup:

extends KinematicBody

func _ready():
	print("Rotation: " , self.rotation.y)
	print("Rotation degrees: " , self.rotation_degrees.y)

func _process(delta):
	if Input.is_action_just_released("rotate_left"):
		rotate_y(deg2rad(int(90)))

		print("Rotation: " , self.rotation.y)
		print("Rotation degrees: " , self.rotation_degrees.y)
		print("Tasto Q premuto")

I want to make the rotation smooth. Also i noticed in the prints that my object @180 degree print a value like

Rotation: -3.141593
Rotation degrees: -179.999985

I understand the first one but not the second. Doesn’t the second be 180 ?

:bust_in_silhouette: Reply From: magicalogic

Multiply your angle by delta.

Nothing, I just want to replicate the rotation in games like Etrian Odyssey. In short, when I press the Q key, the kinematic Body rotate itself of 90° then stops

Flipp3rix | 2021-05-17 12:53

Use lerp() or lerp_angle() then. Check the docs for more info on that.

magicalogic | 2022-05-31 18:09