mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

How to center a gameObject in a road

Open duartebarbosadev opened this issue 3 years ago • 1 comments

Hi, Can anyone tell me how I can center a gameObject (for example a vehicle) in the middle of the closest road?

duartebarbosadev avatar Jan 10 '22 22:01 duartebarbosadev

@DuarteBarbosaPT there isn't an easy way to do it. SDK has a system to process road data and that's pretty much all. What you need to do is;

  • Keep track of them all, probably in a quad tree like structure to be able to query by location.
  • Then query that structure to find the closest road segment to the given point.
  • And finally create your gameobject in the middle of the found road segment. hope that helps.

brnkhy avatar Jan 17 '22 15:01 brnkhy