I’ve been having a go at this for almost 48 hours.
Can someone help me out here please?
# Model - player
# setup a collision solid for Mod1
self.Mod1Col = self.initCollisionSphere(self.Mod1, True)
# set up bitmasks Mod1 can only collide into things
# Mod1 will only collide with objects with this bitmask
# add Mod1 to the traverser
base.cTrav.addCollider(self.Mod1Col , self.tileColHandEvent001)
# Model 001
# setup a collision solid for tile model
self.tileCol001 = self.initCollisionSphere(self.tile001, True)
# set up bitmasks tile model can only be collided into and will collide with the other object
# add tile model to the traverser
# accept the events sent by the collisions
self.accept('into-' + self.tileCol001, self.collide1)
self.accept('outof-' + self.tileCol001, self.collide2)
def collide1(self, collEntry):
def collide2(self, collEntry):
This works fine.
However, I want the same thing to occur on different tile models the player collides with. Let’s say I have two more different tiles, and I want them to change color when the player collides with them. How might I go about this?
Well, right now I don’t have Panda or Python installed on my computer, so I can’t really give you code to look at, but basically what I was trying to say is that you take the code that worked on the first tile and re-use it on all the other tiles in your game.
Exactly how you do that is probably a matter of personal preference, but what I would probably do is create a tile class that inherits from DirectObject and have each one listen for it’s own collision events.
Thank you so much for replying. I really appreciate it.
I had tried this before. The first and third tile responded fine, but when the character collided with the second tile, an event occurred on the third tile. I checked and tripled checked to make sure I had not made a mistake. All the codes seemed fine, but time and again the problem occurred.
However, I really appreciate your taking interest to respond. I will keep trying till all efforts are exhausted. Thanks again.