collisionHandlerEvent problems

When I am trying to use collisionEventHandler() I get an error:“can not concatenate a ‘str’ and ‘module’ object” pointing out that line-

self.accept(‘into-’ + self.obj, objColl)

self.obj has to be something that can be convertet to a string. then you can do like this:


self.accept('into-' + str(self.obj), objColl)

That is true, thanks.
If I use collisionEventHandler(), I can not use collisionHandlerPusher() ?

CollisionHandlerPusher inherits from CollisionHandlerEvent, so you can use a CollisionHandlerPusher and also take advantage of all of the event-throwing logic.

David

But the problem is: when I first define colloisionHandlerPusher and after that CollisionHandlerEvent, pusher doesn’t work. Another way around is better, but it seems that Event doesn’t work. And I want them both, Pusher for pushing against all big geometry and Event only in some special cases. What do I miss here? Example could help :wink:

You don’t need to create a CollisionHandlerEvent if you have already created a CollisionHandlerPusher. The CollisionHandlerPusher is a CollisionHandlerEvent. It pushes things out of walls, and it also throws events. Anything you can do with a CollisionHandlerEvent, you can do with a CollisionHandlerPusher.

David

how do I then add the same sphere to traverser 2 times, once I want it just to be pushed away from some object (just like the usual pusher is doing) and the other time I want it to react in a special way with some other objects? Is it possible?

Do you mean you want it to do both behaviors in the same frame? Just add it once, with a CollisionHandlerPusher, which will handle the usual pusher behavior, and also write your Python code to listen for the collision event and do whatever additional behavior you want it to do.

If you mean you want it to push only out of some objects and not out of others, the easiest way to achieve this is to set the “intangible” flag on the objects that you don’t want to do any pushing. In either case, tangible or intangible, you’ll still get a collision event, but the “intangible” objects will be otherwise ignored by the pusher.

David

Hello,

When you talk about setting “intangible” flag, do u mean setting a bitmask that won’t match for collision detection or do you mean setting a flag like “barrier” in the egg file?

There is a special flag on a CollisionSolid that you can set. It’s actually the “tangible” flag, so when I said set the “intangible” flag, I really meant to set the tangible flag to 0.

cs = CollisionSphere(0, 0, 0, 1)
cs.setTangible(0)

When this flag is set to 0, the CollisionHandlerPusher will allow you to walk through the object, but doing so will still trigger the event.

You can also set the intangible flag from the egg file; use the object type “trigger” (instead of barrier) to make intangible polygons, or “trigger-sphere” (instead of sphere) to make an intangible sphere.

David