Topic was automatically imported from the old Question2Answer platform.
Asked By
Forward
Old Version
Published before Godot 3 was released.
Need some advice on AI. Plan is to have them move around until they spot the player. Once spotted attack and move to the player.
Currently my enemies in game are KinematicBody2D. Would it be better to make them under a navigation 2D to use GODOTs navigation nodes to move them around? I don’t have a lot of experience with AI so any advice would be great!
There is no best way because “AI” is a too broad subject.
So far i’ve been doing simple AIs, they were almost always based on a state machine idea in mind.
I had a script with a state variable, then I execute a different _process function based on that state. In any given state, if some condition is met (player seen, player escaped, took damage…) I change the state variable to go to another behavior in reaction to what happened, so the AI can start running after the player, escape, or go back to patrolling.
There are more complex ways to do AI such as behaviour trees, genetic, and algorithms such as pathfinding are often useful when implementing them (Godot has pathfinding utilities for that, like Navigation2D as you said, or the AStar class).