I'm making a simple 2D, top-view simulation of an evacuation, sprites running around, looking for exits, going at it, all that good stuff.
I have no control over them when the simulation is running, I just program their behaviour.
I'm using the simulation space provided by JADEX, but I'm just using the simplest of what it provides, so it comes down to Java and OOP.
I already have collision detection working, each person has a radius and I search for objects within that radius, so my question is focused on the aftermath.
Say two people collide and one gets pushed to the ground while the other keeps going. No problem so far, but in the cicle after the collision they will again register a collision - since they are still close enough to each other - and trigger a confrontation.
Is there any general or already known technique to deal with this?
Or should I instead focus on another way of detecting a collision?
The expected cases are, when two people collide:
- They are both up
- One is up (D0) and the other one is down (D1).
In case 2, there are two outcomes:
- D0 helps D1
- D0 tramples D1
In case 1 there are 3 outcomes:
- Both are aggressive. Dices are rolled, one keeps going the other one goes down and his physical condition deteriorates.
- Both are non aggressive. Physical condition is compared, winner keeps going, loser is pushed but not to the ground, physical condition does not suffer.
- Only one is aggressive. He will always be the winner. Rest as in 1).
As suggested, I will start by having people maintain a list of objects they just collided with and add an extra comparison to that list in the collision detection to filter them and also make sure that when they are no longer colliding to remove them from that list and see how far that takes me.