AI FSM Using Animator

Hi,

I want to ask a question about using FSM for AI decision making system.

I make a basic AI FSM system for my game. For melee enemies can be in 2 state; ‘Seek For Player’ and ‘Attack’. The transition between this states depends on distance. This works very well.

But what if I create a ranged enemy type? In this case the transition between ‘Seek For Player’ and ‘Attack’ not only depends on distance but also depends on obstacles in the world. Like when the ranged enemy reaches the attack distance, I want also look for is there any obstacles between the player and ranged enemy. If there is no obstacle then the state changed to ‘Attack’ state but if there is obstacle then state changes the ‘Change Position’ state.
This example can be extended for other enemy types like enemies that uses general Melee Enemy states(Seek and Attack) but also have one extra state that depends on different parameter.

I only think to solve this create FSM for all enemy types. Is this the solution or this can be achieved only one FSM for covers all enemy types?

General Melee Enemy Type FSM => Seek For Player, Attack
General Ranged Enemy Type FSM => Seek For Player, Change Position, Attack
Melee Enemy Type with Extra State => Seek For Player, Charge, Attack
Boss Type 1 => Seek For Player, Do Ranged Attack, Do Melee Attack, Change Position etc.

Thanks in advance.

If you only have a small number of different enemy types I’d suggest using a unique FSM for each. That way you maintain control and if something needs to be changed for one enemy type you don’t risk breaking all the others.

1 Like

Thank you for replying. Yes I have a small variety of enemy types, and I can easily create FSM for each. But is there any way to do something like, do the general melee enemy behaviours but also do extra behaviour(s)?

Just add another state and extra transitions with different conditions

Ok I can do that, but in this case all enemies try to enter this newly added state. How can I prevent this?

In this FSM there is a chargeDistance parameter but not all enemy types have this parameter. If put this FSM on all enemy types it is not work right?
Only case this might work by adding additional string parameter for enemy type I think.

3473904--276050--enemyFsm.PNG