- Home /
Follow Dynamic Path At Runtime
I would really like to make a city builder type of game, but one thing holding me back from doing this is making objects such as cars/trains/etc follow a path that is defined by the player with roads/rails/etc. So I can't really use the editor to make a path, as it needs to be done as the player is playing the game.
What do I need to do to accomplish this type of pathfinding/following?
Answer by Kiwasi · Sep 08, 2014 at 11:31 PM
A* is one solution
Waypoints and set paths is another
I looked at a waypoint video, it seems like a good idea. Which solution would you suggest to use? Isn't A* more for finding the shortest way between point A and point B though? For some reason I don't see it being useful in a city builder game. $$anonymous$$aybe it would for finding the shortest path using the waypoints though...
You don't really have a good description of your game, so I gave you both options that would work. If your AI needs to choose its path between specific points in your city then A* is your friend. You could easily programme an agent to choose between walking, car, train ect.
If you want a generic train to run up and down the tracks then just set a bunch of way points.
Answer by Godfather-Games · Sep 09, 2014 at 02:29 PM
A* is a pretty bad solution. A* creates almost perfect paths, that's something you don't want for an AI which behaves like a citizen, car, or whatever. And it isn't a really good solution for calculating dynamic paths.
And yea, don't forget, it needs a lot of memory and can cause CPU problems pretty pretty fast !
You should have a look at recursive backtracking, just google it, there are some articles about it.
But so far, I would recommend you to start using simple waypoints and use their positions for setting up paths.
Answer by Reinholdt · Sep 10, 2014 at 07:12 AM
Hi Regarding dynamic paths you might want o take a look at Apex Path it might be a solution you can use for this! https://www.assetstore.unity3d.com/en/#!/content/17943
Your answer
Follow this Question
Related Questions
A* Formations 1 Answer
My "Smooth Rotation" Jerks around randomly when switching between points. 0 Answers
Follow curved path plus also swipes 1 Answer
Movement and animation 1 Answer
When the development team will implement 2D Navmesh? 0 Answers