Topic was automatically imported from the old Question2Answer platform.
Asked By
DarkLord
My enemy follows my player using Navigation 2D. But problem is my enemy doesn’t look at my player when following it. How do i make it look at my player?
To make the enemy look at player, you need to set rotation of your enemy.
You need to use vector algebra here,
#enemy.gd
func _process(delta):
#position of player minus enemy position will give us direction
Vector2 dir = player.position - position
#get angle from direction (Note roation is in radians)
rotation = dir.angle()
if it is not pointing towards player add or subtract 1.57 (90 degrees in radian) to rotation