What to do about a simultaneous collision?
Hi
I have a problem with a simultaneous collision as follows:
- I have 5 players and 5 boxes.
- Each player must collect a box.
- When each player has collected his box, the level ends.
- Everything is moving at a reasonable speed
The Code is: - when the player overlaps the box I subtract 1 from a variable
- delete box & player
- when the variable = zero the level ends.
Now what happens on rare occasions is that 1 player will run into 2 boxes at the very same split second.
The boxes can also be overlapping each other when the player runs into them - so literally it is the very same split second.
In this case the level will still end normally as they both will deduct 1 from the variable and the player and both boxes are deleted.
But then there is a player left in the level without a box.
And well, I just don't want 1 player to be able to collect 2 boxes.
But I don't have any ideas on how to prevent this.
Any suggestions?
Thanks