Hello everyone,
I'd like to make a system so that the character moves on a road with nodes, when the player “double-clicks” on an orange point with the mouse, he looks for the way to get to that node by moving on the node closest to where he is until he reaches his destination, the character can only move on the yellow road.
Example: Current position = A1, destination = D1, look for the nearest node on the way to D1, and so on, I don't know if I'm clear, so the answer is: B1 - B7 - D1
Example: Current position = D1, destination = C1, the answer is: B7 - B1 - B6 - B5 - C1
Example: Current position = B3, destination = C2, the answer is: A1- B1 - B7- C2
Example: Current position = B2, destination = C1, the answer is: a1- b1 - b7- c2 A1- B5 - C1 A1- B5 - C1
Special case :
Example: Current position = C1, destination = B2, the answers are.
either : B5 - A1 - B2 (The most direct but...) Or B5 - B6 - A1 - B2 (Less direct but Noeux B6 is closer than A1, here B5 - A1 - B2 seems to be the best choice)
There's also = B5 - B6 - B2 (A1 is closer than B2)
You see what I mean, how am I going to do it? I'm not going to do them all 1 by 1, too much work, any ideas?
I've created a yellow road map, I'd like my character to move only on what's in yellow with the pathfinding, I don't know how to do that, any ideas?