Alright so I've been playing GTA a lot and thinking about ways that the GPS feature may have been made. Plus, I might be using a GPS in and upcoming game
Anyways, lets say there is a node at every intersection of completely linear roads. When the player uses the GPS, it firstly finds the closest node to the player as a starting point and the closest node to their destination as an ending point. A function is run through this line between 2 nodes that goes to the middle of the line and finds the closest node to that point. The start then connects to this middle node and the middle node connects to then end, forming 2 different lines. That function is then executed on these 2 lines and repeated until all of the lines match a road. This is just an untested idea, so it's probably bound to fail, but what do you think of it? |