Topic was automatically imported from the old Question2Answer platform.
Asked By
Scorch
I want an object, an eye, in this case, to smoothly rotate to look at the player. How would I achieve this? A full code example would be greatly appreciated!
you can use move_toward to smoothly rotate to the player.
func _process(delta: float) -> void:
# gets the angle we want to face
angle_to_player = global_position.direction_to(player_position).angle()
# slowly changes the rotation to face the angle
rotation = move_toward(rotation, angle_to_player, delta)
With the following code I get errors:
“Cannot find property “angle” on base “Vector3”.”
“Function “angle()” not found in base Vector3.”
Any clue what I’m doing wrong?
Scorch | 2023-05-03 14:55
Vector3 doesn’t have an angle method unlike Vector2, you can do this instead