Hi, I’ve been using Panda 3d for about 3 weeks now and have had pretty smooth sailing so far. I’m currently trying to make a 3d fighting game, however I’ve run into a snag with the collision checking.
class Game(ShowBase): #The Game
def __init__(self):
ShowBase.__init__(self)
self.player = []
for i in range (2):
self.player.append(Beta(i)) #append Character class to player
self.level = Dessert(self.loader,self.render,self.camera) #loads level
self.taskMgr.add(self.updateTask, "update") #loads the Task Manager
base.cTrav = CollisionTraverser()
self.notifier = CollisionHandlerEvent()
self.notifier.addInPattern("%fn-into-%in")
base.cTrav.addCollider(self.player[0].RightFistCol ,self.notifier)
self.accept("RightFistCol-into-HeadCol", self.OnCollision)
def OnCollision(self, entry):
self.From = entry.getFromNodePath() ### is it possible to return player[0
self.Into = entry.getIntoNodePath() ### or 1] using the collision entry???
print str(self.From)
print str(self.Into)
def updateTask(self, task):
self.player[0].action()
self.player[1].action()
self.cameraUpdate()
return Task.cont
def cameraUpdate(self):
self.camera.setX((self.player[1].getX()+self.player[0].getX())/2)
I pretty much want to return the player instance using the entry so that I can use a function from that player to determine the outcome of the collision, or a similar workaround if possible?