Jump to content
  • Advertisement
  • entries
  • comments
  • views

Pathfinding Part 1

Sign in to follow this  


So, pathfinding has been a long-time issue with my SENG engine. The traditional pathfinding I've used is heuristic based. Something like:

  1. Move straight towards the target.
  2. If you hit a wall, walk along the wall until you pass the corner of the wall, and then go back to (1).

    • If you hit something else while walking along a wall, turn around and try to go around the wall the other way.

  • If you hit another actor, pick clockwise or counter-clockwise, and go around that actor until you are clear of the actor.

    1. Picking direction:

      1. Generally, pick the direction that will be the shortest path to the target.
      2. However, if the actor is already going around _you_, pick the same direction as him.

    2. If you hit another actor while doing this, go the same direction around the second actor.
    3. If you hit something else (wall), switch directions.

    For example, in this picture, the actor wants to follow the green arrow. It will follow the red path and successfully reach the target:

    This heuristic works very well in many situations. It goes around actors and pillars very well. And (also important), in terms of performance, it is very inexpensive.

    However, there are a few little issues. The first is that when an actor runs into a long wall (sadly common in things like houses, castles, etc), if he chooses to go the wrong way, he wanders off into the distance aimlessly. Actually, not aimlessly... very directly and without pause.

    The second, and even more annoying, is that if the actor runs into a little indentation in a barrier, he will happily run back and forth within that indentation pretty much forever. This is bad when the barrier is a wall, but if it is something like a river, the actor may be mere feet from his target, with the path to the target in plain view for all, but he simply bounces back and forth.

    For example, in this picture, the actor wants to follow the green arrow. It will follow the red path, and run back and forth forever:

    The final straw for me was when I discovered such an indentation on the last level of 10 Fantasy Fights. It is entirely possible to get the Big Bad Boss stuck in this indentation, and shoot arrows at him until he drops, at no danger to the party.

    Next time: What I did about the pathfinding issue.
  • Sign in to follow this  


    Recommended Comments

    I wish you the best with Path Finding! :) Certain issues I've solved be creating trigger zones to correct incorrect movements, or if I wanted to force a certain movement or several movements.

    Share this comment

    Link to comment
    You'll probably cover this in your next series, but, if not, be sure to check out [url="http://www.policyalmanac.org/games/aStarTutorial.htm"]this great article on A* pathfinding[/url]

    Share this comment

    Link to comment
    Sadly I haven't had a chance to play any games this week! Been so busy with work, and other projects. Thought I would check up on your progress. How's the path finding going?

    Share this comment

    Link to comment

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Advertisement

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!