Retrieving an instanced class during a collision

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):

        self.player = []

        for i in range (2):
            self.player.append(Beta(i))     #append Character class to player

        self.level = Dessert(self.loader,self.render,   #loads level

        self.taskMgr.add(self.updateTask, "update") #loads the Task Manager

        base.cTrav = CollisionTraverser()
        self.notifier = CollisionHandlerEvent()

        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):


        return Task.cont

    def cameraUpdate(self):[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?

you could add a pythonTag to your nodepath, containing a reference to the instance (“self” ). once you get the nodepath, you can simply get it’s tag.

semi-related. if you are looking for a 3d-fighting game there is being worked on for… about 3 weeks now.

Thanks for the reply :smiley: Since I’m only new to this I’m still working out how to manipulate nodepaths, haven’t quite worked out how to create nodes for classes, only within them. However the link you provided is probably the most helpful reference possible. Thanks a bunch!