AI
Overview
Entity AI is done by giving an entity an ordered list of goals to do if a condition is validated. Once an action is found, the entity will be affected by it until asked to stop.
For example, a very simple aggressive creature could have:
Attack target
Walk randomly around
Do nothing
Every tick, the entity will find the goal to follow based on its priority. If the entity has a target the first goal will be used, and the rest be ignored.
Groups
You might find yourself wanting to have multiple goals being executed at the same time. For example, having an entity attacking its target while swimming to avoid dying. This is done by adding multiple EntityAIGroup
to the entity, each group contains a list of goals to be executed independently.
Example
In this example, instances of ZombieCreature will attack nearby players or walk around based on if a player is nearby.
Last updated