BomberUnits
...a Unity learning project
State Class Reference

Extended functionality for Unity SM Behaviours and makes them complete 'States'. More...

+ Inheritance diagram for State:
+ Collaboration diagram for State:

Public Member Functions

bool IsActiveState ()
 Provides a check, whether this state is the current active state in the State Machine.
 
override void OnStateMachineEnter (Animator animator, int stateMachinePathHash)
 Used to set references between SM and states. More...
 
override void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 Extends the normal OnStateEnter function with state tracking for the containing SM. More...
 

Public Attributes

new string name
 Name of the state, to be set exactly as in the Animator View!
 
List< string > triggers
 Names of outgoing transitions allowed for the state, set as in Animator!
 

Protected Member Functions

void TriggerTransition (string transName, float delay=0.0f)
 Shortcut to trigger transitions from within this state for this state (i.e. More...
 
virtual void Awake ()
 Override to use an Awake function, which is not normally available for StateMachineBehaviours.
 
virtual void OnMyStateEnter ()
 Override to use OnStateEnter as extended by this base class. Do not override OnStateEnter!
 

Protected Attributes

StateMachine sm
 Reference to the State Machine featuring this behaviour.
 

Detailed Description

Extended functionality for Unity SM Behaviours and makes them complete 'States'.

Only one such state is currently allowed per State Box in the Animator Controller!

This is intended to provide safer transitions by enforcing checks for whether a transition is allowed for a certain state. This prevents carry-over or false trigger flags to the next states. To do this:

  • state name and allowed triggers are listed when in the SM editor
  • These are checked when a state transition is requested.
  • Only the currently active state can be the source for triggering a transition.

The base classes offer for inherited behaviours:

Definition at line 20 of file State.cs.

Member Function Documentation

◆ OnStateEnter()

override void OnStateEnter ( Animator  animator,
AnimatorStateInfo  stateInfo,
int  layerIndex 
)
inline

Extends the normal OnStateEnter function with state tracking for the containing SM.

Do not override! Instead use OnMyStateEnter in derived states!

Definition at line 84 of file State.cs.

◆ OnStateMachineEnter()

override void OnStateMachineEnter ( Animator  animator,
int  stateMachinePathHash 
)
inline

Used to set references between SM and states.

Unfortunately, this is not called automatically for the base layer and is thus called by the SM. Provides the Awake() functionality for subclasses to use during startup if needed.

Definition at line 71 of file State.cs.

◆ TriggerTransition()

void TriggerTransition ( string  transName,
float  delay = 0.0f 
)
inlineprotected

Shortcut to trigger transitions from within this state for this state (i.e.

leaving this state). It provides an optional delay until the transition is triggered.

Definition at line 45 of file State.cs.


The documentation for this class was generated from the following file: