Hey.
Ive got aggressive NPCs that attack the player if the player comes within a certain square around the NPC (Once the NPC has "seen" the player it will chase him forever). It then follows the player. It finds on which axis the player is further away (X or Y) and move in that direction. (I didnt want them moving diagonnally)
This all works fine. But the problem comes when the NPC is on another side of an un-passable object. The NPC walks right through it. Ive tried getting around this by stopping the NPC on a collision. Then making it decide which direction to go from the position of the player. But i have not been able to get even this to work. For example
X (Player is closer on the right. So go right until you can go down)
=======
P
P = Player
X = Baddie
But this wont work where
|======
|
| X
|=======
Y
The NPC will just go left into the wall and will get stuck.
Note that information is storred in tile maps.
What do you suggest?