I use something similar to below code for calling setAngle()
method:
func _input(event):
if event is InputEventKey:
if event.pressed:
if event.scancode == KEY_R:
$Character.setAngle(225)
When I print rotation_degrees.y
for debug, although the numbers are thought to be integers, they are decimal with precision part. So it's never reach exactly to 0
. When I check it more accurate, I see that when I want to move the object with the below code inside else
statement:
var direction = -global_transform.basis.z
velocity.y += gravity * delta
velocity.x += direction.x * speed
velocity.z += direction.z * speed
velocity = move_and_slide(velocity, Vector3.UP)
It seems that rotation_degrees.y
changes with unknown reason, so when once again _physics_process(delta)
called, The conditions goes true
and so again rotation starts.