# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### Newcomers AppGameKit Corner / Learning 3d waypoint for pathfinding: Determine neighbouring waypoint

Message
Posted: 21st Feb 2018 04:44
Hi all,

I know it is a classic thing to ask in game making and i do aware that we have example here and other places.
But i want to learn from the basic. 2 questions:
1. How do i place the waypoint? and efficiently? do i divide my 3d level as in 2d and evenly place the waypoint as in 2d grid?
2.What is the best and efficient way to determine neighbouring or closest waypoint from one waypoint?

Thanks
Posted: 21st Feb 2018 13:34
Well, it's really up to the map designer where waypoints should be located. Look at your map, where would you make a path? Mark a waypoint at any spot where the character would change directions. Store the coordinates of each waypoint in an array.

Look at the image. Say you're trying to get from the green square to the blue square. The red shows you two paths, which are pre-determined by you. You simple decided where you want to allow people to go on your map. Then yellow squares mark points where a path can change. Those are your waypoints. Each waypoint will point you to the next one. Once you reach it, see where it tells you to go next. Waypoints, in a sense, act as road signs.

In this example, the path splits two different directions. You can either let the user choose which way to go, take the shortest path to the destination (by calculating the remaining distance of each path), or just jump to the next closest waypoint (as you have suggested).

Your waypoints are in an array, so loop through all your waypoints and check your current distance from them. To find the closest, you'll need to check them all, except for two; the one you're current at and the one you just came from (unless you want to just keep walking back and forth). When you've determine which point is closer, move there.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds