Patrol, Chase, and Jumpscare. Horror Enemy AI?

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

How do I make an enemy AI that will look in different rooms for the player; chase the player when they enter the enemy’s field of vision; and jumpscare the player once in the radius of the enemy?

   BTW I'm new to Godot and game making so a detailed answer would be nice. :)
:bust_in_silhouette: Reply From: reshadiye1

Firstly you should learn what is AI?

example i will give an example for you:

enemy.position.x += 50

this is an example ai command. Now i will write a way which way came to my mind. Let’s mix a bit:

if enemy.corridor == myPlayer.corridor: 
   #then probably enemy will see our character
   enemy.attackMode = true  # i opened attack mode, so it will attack.

Let’s look to enemy process:

if attackMode:
 
   if myPlayer.position.x < enemy.position.x:
     enemy.position.x - = SPEED * delta
   elif myPlayer.position.x > enemy.position.x:
     enemy.position.x += SPEED * delta
     if myPlayer.position.y < enemy.position.y:
     enemy.position.y += SPEED * delta
   elif myPlayer.position.y > enemy.position.y:
     enemy.position.x -= SPEED * delta

so enemy will come to our position. Look I am not saying do these, i am just giving to you any idea, you are new in godot so you should improve yourself firstly. Good luck :slight_smile: