Panda3D Manual: Classic Finite State Machine Usage
  <<prev top next>>  

Once a finite state machine has been created, it needs to move through its various states. There are three methods for transitions. Two will automatically move the finite state machine into either the initial or the ending state. The third requires a state to move to, and it will check to see if it is possible to move to this state. If it cannot make the transition, it will print a warning.

fsm.requestInitialState()
fsm.requestFinalState()
fsm.request('State Name')

It is also possible to force a transition, even if one does not exist. This should only be used for debugging. Another helpful method for debugging returns the current state of the finite state machine.

fsm.forceTransition('State Name')
fsm.getCurrentState()

Finite state machines can also be nested through the addChild() command. When a parent state is entered, all child finite state machines transition to their initial state. When a parent state exits, then all child finite state machines will transition to their final state.

StateHandle.addChild(fsm)

  <<prev top next>>