Collision Handler Pusher for characters?

I use the CollisionHandlerPusher to slide my characters when they collide with walls. No problem. The wall is only an into object and the player is only a from.

The problem arises when I try to collide my characters with each other. If I still use the pusher and set the characters to be both from and into object, then when my player collides with one, it will drag that character. I don’t want that, I want only him to slide in that case.

What to do in this kind of situation? CollisionHandlerEvent might be an option, but no idea how to reimplement the pusher effect with my changes.

Dragging, like, pulling behind ? That’s weird…

If you meant pushing, then I’m not surprised that characters can push each other. Indeed, from an implementation point of view, you need the system to be symmetrical.

If two characters are running full speed into each other, then both are pushed away to solve the collision.

Likewise, when one character moves and the other stands still, both are still pushed away.

To have one character only react to the collision would lead to the question: which one? The first one processed by the code ? That would make the order kind of random and arbitrary. The fastest one ? The collision system deals with positions only, not speed.

hey, I’m the one asking questions :stuck_out_tongue:
But if seriously, I’m not sure why you are asking me how that would work. I don’t know, I’m asking myself.

Not sure if I understand you right, but when a character (into) object collides with a wall, they are both colliding. Just because the wall didn’t move doesn’t mean it didn’t “react to collision”. So I’m not asking how to make only one react to collision, because that wouldn’t do anything. I’m asking how to prevent them both from being both from and into when they collide with each other, I guess.
How? Well, that’s what I’m asking. But obviously there is some solution, looking at existing videogames.

Oh sorry! These questions were not meant to you. They were general. I just have the habit, when facing a software problem of any kind, to wonder how I would have implemented it if I had to do it myself. So, if I had implemented Panda’s pusher, I would have made sure that its behavior was symmetrical. I am not sure that Panda is implemented that way, but it may be because that would explain the behavior you’re observing.

Just to make sure I follow you: you have two characters, A and B. When should A be pushed away, and when should B be pushed away, when Panda detects that A and B are overlapping?

Bump.

When the topic has a reply it seems from the first sight that it might be solved, or answered.

A should slide along B when it is moving, leaving B alone, and B should slide along A when it is moving, leaving A alone. When both are moving though, both should be able to push each other.

Panda doesn’t think in terms of moving/immobile. All the from-objects are moving, even if they’re moving with a speed of zero.

So, I guess that your application will have to do the work. Only moving characters should be from-objects.

You could have a task that checks whether characters are moving or not.

  • You can do that by comparing their last position (which you have to store yourself) with their current position. You now know if your character is mobile or not.
  • Compare it to whether it was mobile or not at the previous frame (so you need to store that too). That tells you if the character started or stopped moving.
  • In these cases, add/remove the character to/from the from-list.

Instead of updating the list of from-objects of the handler, setting the fromBitMask to 0 may do the trick.

Okay then, maybe I can change the design then to simplify stuff.

How about your character can’t push NPCs, only NPCs can push you? That seems to be the case in some games.

You can only be pushed back if you’re a from-object. So if NPCs can push you and you can’t push them, it means that you are a from-object and they are into-objects.

We still want to prevent PNCs to penetrate each others though, so NPCs should be from-objects as well.

Maybe masks could help?