Some odd collision detection hierarchy problems...
BlitzMax Forums/BlitzMax Beginners Area/Some odd collision detection hierarchy problems...
| ||
So I am making a game that plays somewhat like the Tron lightcycles. Each player leaves a trail of connected points as they move. If a player touches their own tail they die, if they touch an opponent's trial they die and the opponent continues on. My problem currently is figuring out a situation where they both collide at the same time resulting in a draw - eliminating both players. The problem is that I can only check for collisions player by player and there are some situations where even if the collide at the same time there is still a victor. My current system employs players who have a list of lines behind them and each player checks to see if he has crossed an opponent's trail. If so he kills himself. The problem with this method is that the first player processed will always be at fault and removed before the next player can see if he is at fault. If both collide head on the first is removed before the second detects it. Technically they should both be at fault. |
| ||
Do not immediately delete the trails, simply mark the player for deletion (add an IsDead field or something similar), and then delete the players and trail in a separate loop after they've all been evaluated. |
| ||
When you loop through all the players, just flag them as dead if they crossed a trail. Then loop again killing those with the crash flag. |
| ||
I'll give that a try, thanks. EDIT: There is a new problem with this method. The problem is that it kills both players, even when one is clearly at fault... ![]() |
| ||
The last player to reach the intersection point will have collided with opposing players track and will be the looser. So determine time to intersection for each player. |
| ||
or the one closest to the intersection. |
| ||
Thanks gents, I will implement this tomorrow. It seems that many relatively simple concepts create some complex coding. |