Finite State Machine - no request in module?

Im trying to learn about Finite State Machines (FSM) and have followed the manual closely, yet when I try to request my state from my FSM class, it always returns an error:

So I tried to use forcetransition, and error:

here is moveFSM:

from direct.fsm import FSM

class AvatarFSM(FSM.FSM):
    def __init__(self):#optional because FSM already defines __init__
        #if you do write your own, you *must* call the base __init__ :
        ##do your init code here
    def enterWalk(self):
    def exitWalk(self):

    def enterJump(self):
    def exitJump(self):
movefsm = AvatarFSM()

and here is the pertinent info:

import movefsm
import direct.directbase.DirectStart 
from import Actor
from direct.fsm import FSM

def move(self, task):
     if (self.keyMap["jump"]!=0):

Any suggestions on why it wont use the FSM commands?

Well, you’re probably calling the FSM module instead of the FSM class somewhere. There’s a difference between this:

from direct.fsm import FSM 

and this:

from direct.fsm.FSM import FSM 

Thank you for your quick reply :wink:

However that change returned to me this:

import movefsm
  File "", line 3, in <module>
    class AvatarFSM(FSM.FSM):
AttributeError: class FSM has no attribute 'FSM'

I am trying to follow the manual close, is there something else I am missing?




Also, better use a different name for the module and global variables. It is quite confusing sometimes.

Sorry for not posting back, been very busy - But thank you very much chleung and pro soft the info you provided was key.