Get enemy AI to move around walls better.

Hi everybody,

I'm making a top-down tank game. In the game there are walls and obstacles that you need to move around to shoot the enemy tanks. It's easy for the player to move around them, but the enemies get stuck behind the walls. Is there a way of having them move around walls, and not run into them.

This is my logic for the enemy actor to move to the player actor. I have two attributes constrained to the players X and Y position. Then,

Enemy Actor: MoveTo PlayerPositionX and PlayerPositionY

So, if the player is behind a wall, and there's an enemy on the other side the enemy will just run into the wall trying to get to the player X and Y, instead of moving around the wall.

Best Answers

  • sparkaniasparkania Posts: 300
    edited December 2012 Accepted Answer
    Well.. I don't know much about doing ANY AI in GS.. but I do have 2 ideas how you might fake-the-funk..

    Either.. make a few hidden actors to use as way points. at the corners of whatever obstacles they are getting stuck behind ie.. make a collision condition on the main let's say Wall, that if your bad guy hits it, then they are to move to the waypoint actor, then when they overlap the waypoint actor, put in another collision command that puts them back on course to kill you..

    another way, if your obstacles are not creating a pocket of sorts, put a big oval hidden actor over them with a circular collision. this will not stop your enemies, rather it will make them appear to move around the obstacle instead of hitting it.
  • domeniusdomenius Posts: 108
    Accepted Answer
    I may have a solution for you, check out: http://forums.gamesalad.com/discussion/50651/simplefinder-introducing-easy-pathfinding-for-your-projects#latest

    My pathfinding library provides a drop-in solution that should do exactly what you need. If you are interested in purchasing it, pm me.

Answers

Sign In or Register to comment.