Here I explain how I implemented the enemy state machine, which is fully functional in online multiplayer as well.
ENEMY
The base script for all enemies. It is responsible for continuously updating the state machine.
It is important to note that this is a networked class, and only the host is responsible for executing enemy AI logic.
ENEMY STATE MACHINE &&
ENEMY STATE
EnemyState defines the structure and behaviour shared by all enemy states.
The EnemyStateMachine is responsible for managing state transitions and controlling which state is currently active.
STATES
Each concrete state inherits from the EnemyState base class, defining the different behaviours available to the enemy.
Within each state update function, logic is delegated to a ScriptableObject that contains the specific behaviour implementation.
This approach allows multiple enemy types to share the same state structure while still performing different actions depending on their configuration.
DIFFERENT ENEMY TYPES
Each enemy type inherits from the base Enemy class.
These derived classes are mainly responsible for initializing the state machine and configuring the specific states required for that enemy.