- Home /
What path-finding technique do I use?
So I have this 2D game that I am working on and it takes place in a building. What I need is a pathfinding solution that will make my player go to a specific destination in the shortest path. Here is an example of my level:
So here is the problem: You start at ROOM 1 and must go to ROOM 4. In order to travel between rooms, you must go through each door (the brown squares). Each door will lead to the corresponding shape found on top of the door. If I go through the door that has a Triangle on top, I will come out the other door that has the Triangle on top.
So, how do I create (or implement) a pathfinding solution that will get my AI from Room 1 to Room 4?
The image is not showing for me, but this sounds like your doors are acting as teleporters? If so, you can use the inbuilt Nav$$anonymous$$esh, defining off-mesh links between the doors http://docs.unity3d.com/Documentation/$$anonymous$$anual/Off$$anonymous$$eshLinks.html
I dont have Unity Pro. Sorry. Also, I do not believe that will work in this case since my game is 2D. $$anonymous$$y AI can only move left and right. Also, here is a link to the image: https://www.dropbox.com/s/n5hfb0dc6z3l7vr/LevelExample.png
Someone please help. I am totally stuck. I just need AI in my game and I am done, so pleassse help
Answer by Jeff-Kesselman · May 10, 2014 at 11:01 PM
You can actually do a classic A* with this no problem.
You just need your A* to know the teleportation points. The square on the other side of the teleporter is treated as a "neighbor" for purposes of the A* algorithm.
Answer by Mr.Hal · May 10, 2014 at 02:40 AM
I'm facing a similar problem, Waypoints are what you want, if I had to guess how the structure would be, Have a event that executes when the AI is at a door or waypoint and have him move to the next room and have other code that logically finds the required paths and waypoints to get there in reverse from the target to the AI. Then have the AI note the required paths to get there and do them one by one and take them off the stack when the path is traversed or the AI walks to a waypoint.
TL;DR Waypoints, You need them!
Your answer
Follow this Question
Related Questions
Follow up to AI Pathfinding Question 0 Answers
NPC Fleeing with Unity Pathfinding? 1 Answer
Basic Enemy Javascript 0 Answers
A* Pathfinding Project Y-axis movement, help. 1 Answer
A* Pathfinding, destroying a path once it has reached its end 0 Answers