Pathfinding Units Overlap!
Hi everyone, I've got a simple gauntlet clone going and marking where units move on a grid to keep units from overlapping. Things work fine if they only move in 4 directions (up,down,left,right) but diagnol moves cause overlaps.
------------------
| A | B |
| | |
------------------
| 1 | 2 |
| | |
------------------
Unit A to 2 is valid move, unit B to 1 is valid but of course they overlap.
I would like to avoid complicated steering since this is a simple game.
Can someone give me some pointers?
Thanks for the help! -adrian
Depending on the kind of data you have, without adding steering to your system (which ain't that hard, check out Craig Reynold's page for more info), you could check neighbor units and do this test, and probably wait until their move is done before doing yours.
Hope this helps
Hope this helps
You could also hardcode so that if a unit wants to go diagonally, it also has to check the neighbours of that tile.
I.e
Wants to go NW?
if NW, W, N == free
Go there.
else
move straight.
Sort of. :D
I.e
Wants to go NW?
if NW, W, N == free
Go there.
else
move straight.
Sort of. :D
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement