The FSMState class

FSMState manages the transitions to other states. It has a dictionary object called map, which is used to store the key-value pairs of transitions and states. For example, the SawPlayer transition maps to the Chasing state, LostPlayer maps to the Patrolling state, and so on.

The code in the FSMState.cs file is as follows:

using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 
 
public abstract class FSMState 
{ 
    protected Dictionary<Transition, FSMStateID> map = new  
    Dictionary<Transition, FSMStateID>(); 
... 

The AddTransition and DeleteTransition methods add and delete transitions from its state-transition dictionary map object. The GetOutputState method looks up from the map object and returns the state ...

Get Unity Artificial Intelligence Programming - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.