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

Author
Message
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
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
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
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

Attachments

Login to view attachments
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 22nd Feb 2018 07:21
ok..i get what you mean. So this is unlike 2d grid system where i need to find out who to the left,right,up and down. Just iterate thru all waypoint and find the closest except visited waypoint.

Next one, let say in a large box shape hall with 2 door on each wall end. Do i need to put only 2 waypoint before each door? If so, how do the AI chase the player inside the hall?Using raycast?Or put denser waypoints in the hall.

Second one, how about dynamic obstacle?

Thanks

Login to post a reply

Server time is: 2024-11-23 01:10:01
Your offset time is: 2024-11-23 01:10:01