Moving a gameobject from point A to D thru B and C
Basically the process that I want to accomplish, is similar to endless space or stellaris, how they have a starsystem at point A, and you need to get to starsystem D. I dont want it to move in a straight line from A to D though. I want it go to nearest starsystem in that direction say starsystem B then to C and finally D all in one click of the mouse. For the life of me I cant seem to figure out the logic behind it to program it in C#.
I thought about searching for nearest gameobject (starsystem) moving to that point. Then comparing position of that point with the one I wanted it to move to. If its not the same then repeat till it gets there...but...point A will be surounded by other points not just point B . So that wouldnt really work.
If anyone could lend me a hand would be much appreciated.
Answer by Mindmapfreak · Oct 05, 2016 at 09:49 PM
Sounds like a pathfinding problem, take a look at the A* algorithm. Your starsystems would be the nodes. Depending on the number of starsystems you maybe have to limit the number of neighbors the algorithm looks at (if they are distributed fairly even the resulting path should still be optimal in most cases).
Your answer
![](https://koobas.hobune.stream/wayback/20220612094053im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make an object go the direction it is facing? (Im new) 0 Answers
Programmmed Animation (making transform move to vectors with code) 0 Answers
Mouse-Keyboard Not Working - New User 1 Answer
GoogleVR / C# - How to, with the "pointer click": click 1 move a cube and click 2 move back the cube 0 Answers
SImple, but how do I check a game object's position in an If statement? 1 Answer