#I need help making an simple enemy ai

2 messages · Page 1 of 1 (latest)

brave plaza
#

From how you describe it, it seems like a simple state machine can handle all your needs. You can set it up so that it has two states: idle/wander and chase, and have your agent switch between them whenever the player object enters/leaves its [Area] of influence.

Depending on how your map is built, you may need to use pathfinding to help the enemy AI make its way towards your player.

For the 'trigger' mechanism, you can either add another Area node to detect a 'touch', or by simply calculating the distance between the agent and the player in your tick method.

Here are some links to help you get started:

(Intro to State Machines)
https://gamedevelopment.tutsplus.com/tutorials/finite-state-machines-theory-and-implementation--gamedev-11867

(Godot Pathfinding)
https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationagents.html#navigationagent-pathfinding

Game Development Envato Tuts+

A finite-state machine is a model used to represent and control execution flow. It is perfect for implementing AI in games, producing great results without a complex code. This tutorial describes...

light glen
#

Got it, thanks 🤠