I have this enemy that needs to rotate slowly towards the player with the $WishedDirection indicating the wished direction, but all my previous methods were in vain. Dot products didn’t work, rotational values didn’t work, nothing worked. I skimmed the code from the sounds.
func get_input():
pass
func _physics_process(delta: float) -> void:
var dec = $WishedDirection.get_collider()
if dec:
if dec.is_in_group("player"):
if canfire:
var instance = projectile.instantiate()
add_sibling(instance)
instance.global_position = $Launcher.global_position
instance.transform = $Launcher.global_transform
canfire = false
velocity *= 0.95
else:
$WishedDirection.look_at(global.playerpos)
velocity = transform.x * 1.0 * speed
get_input()
rotation += rotation_direction * totalrotationspeed * delta #the main thing
move_and_slide()
If you succeed in finding the solution, I’d appreciate it very much!