Enemy looking at player

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

I want my enemy to look at the player, can someone write an example code?
Here is the Enemy script:
extends KinematicBody2D

var player = null
var Shooting_player = “res://Player/Shooting_player.tscn”
var move = Vector2.ZERO
var speed = 2

func _process(delta):
var dir = Shooting_player.position - position
rotation = dir.angle()

func _physics_process(_delta):
move = Vector2.ZERO

if player != null:
	move = position.direction_to(player.position) * speed
	move = Vector2.ZERO
move = move.normalized()
move = move_and_collide(move)

func _on_Area2D_body_entered(body):
if body != self and not body.is_in_group(“enemy”):
player = body

func _on_Area2D_body_exited(_body):
player = null

func _on_Area2D2_body_entered(body):
if player == body:
get_tree().change_scene(“res://Title + deathscreens/Deathscreen.tscn”)
elif body != self:

:bust_in_silhouette: Reply From: Wakatta
if player != null:
    move = position.direction_to(player.position) * speed