I have a* implemented in my game, the algorithm knows which tiles are walkable and which ones are not, but does not know about enemies.
While performing a path, if my character collides with an enemy, it will declare unwalkable the tiles that the enemy is standing on, which can be from 1 to 4 tiles (the enemy can be in the middle of 4 tiles).
To understand my problem, you have to understand how I execute a path after I found it.
The tile my char is standing on, is the origin tile for the pathfinding, but the character doesnt need to be in the middle of the tile exactly, as the game moves the character pixel by pixel, so, the first move my character makes, is going to the center of the origin tile.
Now, consider this:
Im following my path.
I found an enemy.
The enemy is located within a tile, I declare that tile as unwalkable.
I start my pathfinding... OH DAMN, my origin tile is the tile where my character is located, which happens to be the same tile where the enemy is, and I cant move to the center of this tile, because my enemy's collision radius (which I use to calculate collisions between characters) envolves the center of the tile.
So now im on a dead lock, I have to move to the center of the tile, but the character to character collision avoidance does not allow that, but my movement system needs to move there to proceed.
I am having a big head ache to find out how to get this done.
One of my problems is that my characters ONLY move in 8 directions (multiples of 45 degrees), that why I move to the center of the first tile, because after that, I will only have to move straight up/down left/right or in straight diagonals from the center of a tile to the center of the next tile till I find my goal.
I think I have spoken a lot, but this has been bugging me for a long time, and I have failed to find a way to get this done.
[Edited by - arthurviolence on December 27, 2010 11:04:57 AM]