Our team is using WRLD sdk for our current project. We are trying to have some objects follow a predefined path of geographic coordinates (basically points from google maps). The problem is that the object do not properly follow the path. We have defined the following path:
new List<LatLong>
{
LatLong.FromDegrees(53.748667, -0.248243),
LatLong.FromDegrees(53.748828, -0.249892),
LatLong.FromDegrees(53.748813, -0.250043),
LatLong.FromDegrees(53.748644, -0.250342),
LatLong.FromDegrees(53.748560, -0.250416),
LatLong.FromDegrees(53.746968, -0.250809)
};
When the objects move from one point to another, it does not follow a straight line and does not closely match the road in WRLD.
This is the code we use to make an object follow the path:
public IEnumerator MoveThroughWaypoints(List<LatLong> path)
{
if (path == null || path.Count == 0)
{
yield return null;
}
else
{
Position = path[0];
VehicleGeographicTransform.SetPosition(Position);
for (int i = 1; i < path.Count; i++)
{
LatLong target = path[i];
while (LatLong.EstimateGreatCircleDistance(Position, target) > 1)
{
Vector2 positionVector2 = MakeVector2FromLatLong(Position);
Vector2 targetVector2 = MakeVector2FromLatLong(target);
positionVector2 = Vector2.MoveTowards(positionVector2, targetVector2, Time.deltaTime / 3000);
LatLong result = LatLong.FromDegrees(positionVector2.x, positionVector2.y);
Position = result;
VehicleGeographicTransform.SetPosition(Position);
yield return null;
}
}
}
We welcome any suggestions to try to solve this issue.
Thanks ![]()