The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

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. :)
Godot version Godot 3.0 (GLES2.0)
in Engine by (13 points)

1 Answer

0 votes

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 :)

by (72 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.