Collision event with loaded geometry

Hi,
I am attempting to have a CollisionEvent with a loaded model as the ‘into object’, but I can’t seem to get it to work. Here is what I have:

 self.Centerroom = NodePath('room')
 room1 = loader.load_model('../models/CenterRoom.glb')
 room1.reparentTo(self.Centerroom)
 self.Centerroom.setCollideMask(BitMask32(0x2))

 pusher.addInPattern('%fn-into-%ig')
 traverser.addCollider(self.camHB, pusher)
 self.accept('camcollider-into-room', self.handleWallCollision)
   
 def handleWallCollision(self, entry):
    print(entry)`

Am I using the wrong string to refer to the model, or missing something else entirely?

Hello.

The in pattern you added uses “%ig” instead of “%in”.
So, the event name getting thrown is probably

"camcollider-into-g"

Instead of

"camcollider-into-room"

if you want, you should be able to check this from the command prompt with

messenger.toggleVerbose()

Also, I double check which name the event manager will throw. After checking with render.ls(), I think it might be “CenterRoom.glb”

I used ‘%ig’ since the into object is a geom, and not a collision node, detailed here.
When I use render.ls(), I see that the geom is named “plane.001”, so I changed

"camcollider-into-g"

into

"camcollider-into-Plane.001"

which still doesn’t work

Hmm…
have you used messenger.toggleVerbose() to check what name is thrown when the collision is intended to occur?
With toggleVerbose(), the name of every event is printed out when that event occurs. So if it doesn’t appear at all, that may indicate that something else is going wrong.

Yeah, I have used messenger.toggleVerbose. this is the event that gets thrown with the collision:

sent event: camcollider-into-c sentArgs = [render/camera/cam/camcollider into render/room/Scene/centerroom/Plane.001 at 16.2447 10.0212 3.85415], taskChain = None

So it looks like its still “Plane.001”. Would you have any idea where else it could have gone wrong?

It looks like the event name being sent is

"camcollider-into-c"

thus, plane.001 is a collisionNode.

However, I did just realize the problem.
It looks like you might have forgotten to set the collide mask for camcollider, like so:

base.camera.setFromCollideMask(BitMask32.bit(0x2))

important
Keep in mind that it’s not always a good idea; especially in visually complex games; to run collisions against visual geometry as it tends to be very expensive.

That was it, Thanks!