Hi guys,
Nice to meet you. As you might see I’m pretty new to the engine and to the forum. I have been reading the manual for a couple of days and tried to do a basic FSM with a basic Event Handler. However, it doesn’t seem to be working,particularly it doesn’t enter the enterWalk() def.
Here’s the code: Note: I’ve left the printing statements used for debugging.
from direct.showbase.ShowBase import ShowBase
from direct.showbase import DirectObject
from direct.actor.Actor import Actor
from panda3d.core import Point3
from direct.fsm import FSM
p3dApp = ShowBase()
pandaActor = Actor("models/panda-model", {"walk": "models/panda-walk4"})
pandaActor.setScale(0.005,0.005,0.005)
pandaActor.reparentTo(render)
pandaActor.setPos(0,15,-2)
class movementFSM(FSM.FSM):
def __init__(self,actorName):
FSM.FSM.__init__(self,'movementFSM')
self.actor = actorName
def enterWalk(self):
print 'Enter'
self.actor.loop('walk')
def exitWalk(self):
# slef.actor.stop()
print 'Exit'
pF = movementFSM(pandaActor)
class myEvH(DirectObject.DirectObject):
def __init__(self):
self.accept('w',self.requestWalk)
def requestWalk(self):
print 'Accepted'
print pF.state
pF.request('walk')
h = myEvH()
p3dApp.run()
Can anyone see what’s the problem?
Thanks,
Norbert