Ok this should be relatively simple. I have four colspheres around four objects (I can see them) and when these objects collide, I should get a print statement.
CollisionTraverser requres that you call cTrav.traverse() every frame. Note base.cTrav does that for you … maybe this is where the confusion comes from?
The collision traverser checks whether any collision have occurred. There is one built-in collision traverser, that is called automatically every frame: base.cTrav
If you create any other collision traversers (for example, self.cTrav, as you did), you should call it manually by
self.cTrav.traverse(render) # you can use some other nodepath instead of render, if needed
You also need to add collision handler and colliders to the traverser, so that it knows what collisions to determine.
Then, you need some active collision node (“from” node). You only have passive “into” nodes. You can compare the “from” node with a drunk man, and the “into” node with walls and road this man collides with.
PS: The “from” nodes can also collide with each other (if they have the same collide mask, of course), just like two drunk men can. If they have different collide mask then, of course, they won’t collide with each other, just like drunk man won’t collide with drunk spook; this is because they have different collide masks
I think you can check by running your code with messenger verbose
Here your second line will replace the effect of first line.
So the event fired will always be “player2Sphere-into-wall” whatever collision is detected
So the function self.pl1Into2 will never be called because the event
“player1Sphere-into-player2Sphere” will not be sent.
self.cHandler.addInPattern(‘%fn-into-%in’) will send the event you look after if name of sphere1 is player1Sphere and name of sphere2 is player2Sphere
if object 1 is player1Sphere and object 2 is wall then event fired would be
“player1Sphere-into-wall”