Problem with CollisionHandlerPusher

I want the player to be able to walk up to an object and press a button to collect it. But I don’t want him to go through the object.

I know how to use CollisionHandlerEvent and CollisionHandlerPusher. But since Pusher “pushes” the actor back, it’s not colliding anymore (technically).

What I want is this:

  • Character collides with pusher object (cannot pass through object)
  • Event function detects if collision has happened. Player can press spacebar and collect the object ONLY IF he is colliding with the object.

Is there a way to combine CollisionHandlerEvent and CollisionHandlerPusher to make this work? Or can I use two collision solids (or nodes), one to push back on the actor and one for events?

As far as I know (I just started with Panda recently, and haven’t done too much with collisions), combining the two handler types would not work. You’d have to set up both handlers anyway, and add the character as a collider for both, and then I’m not sure you’d get a collision for the event handler either.

Your options as I see it are the following:

  • Give your actor two collision node sets (the one for the even handler slightly bigger)
  • Use a task that sees if your actor has moved as much as he would have, if not for the pusher (that is, see when the pusher is acting on the actor). Set up a Vector, which you apply all movement to that you do to the actor, and then compare that plus the old location to the new location. (This would have to be done all the time though, else you’d get ‘has the character moved since the last time you pressed space’. This way you have a task that sets actorPushed to either True or False, and an event that simply returns that value.)