How to get a list of objects that overlap/touch the selected BoxCollider, but after pressing a button on the keyboard?

I have an object collider made (several cubes: Box1, Box2, Box3 and one main MainBox that overlaps/touches the others). When I start the game, I get information about the collision (the mentioned 3 cubes have collision with the main one) – and that’s great. I would like, to be able to now call again the collision between objects (get CollEntry), with which the main cube intersects, but without moving them.In short I press the “L” key and get the information that Box1, Box2 and Box3 are in collision with the MainBox.
Thank you in advance for your help.

I think you, at the click of a button, should simply call the traverse() method, passing it the node on which your objects are located.

col_trav = CollisionTraverser()

def my_fun():

base.accept('l', my_fun)
1 Like

I get collision with start game, but executing self.cTrav.traverse(self.render) not working.

        self.cTrav = CollisionTraverser()

        # Initialize the handler
        self.collHandEvent = CollisionHandlerEvent()
        self.accept('l'. self.my_fun)
    def my_fun(self):

If the outer boxes never leave contact with the inner box, then they never “re-enter” it, and so won’t produce subsequent “in” events. (Or any “out” events, for that matter.)

However, as they continue to be in contact, they should produce “again” events. These are handled just as with “in” and “out” events, like so:


As a side-note, let me say that I don’t recommend the use of “cTrav” for this purpose: Panda’s collision system automatically has “cTrav” run a traversal on every frame, and as a result, you’ll presumably get events every frame, whether you want them or not–and then extra events when you manually call “traverse”, I believe.

Instead, I suggest creating a separate traverser, one that you can instruct to traverse as and when you desire–as shown in serega’s example, above.

1 Like