Topic: Use LineRenderer to draw route
Hey,
For few days, I'm using the drawing API to draw route on my tileset map (use on a raw image, UI). Without any route, my app running up to 900 fps. At the moment I use the drawing api, I drop to 20-50 fps. So i searched on the forum and i found that LineRenderer could be a solution. So I searched for some example, and I didn't found what I was searching for.
Using this code :
LineRenderer lineRenderer = map.AddComponent<LineRenderer>();
lineRenderer.sharedMaterial = lineRendererMaterial;
lineRenderer.useWorldSpace = true;
lineRenderer.widthCurve = AnimationCurve.Constant(0, 1, 2);
lineRenderer.startColor = lineRenderer.endColor = Color.blue;
lineRenderer.positionCount = coords.Count;
for(int i = 0; i< coords.Count; i++)
{
Vector3 p = OnlineMapsTileSetControl.instance.GetScreenPosition(coords[i].x, coords[i].y);
lineRenderer.SetPosition(i, new Vector3(p.x, 2, p.y));
}
The violet lineRenderer is not at the right position and not in the right direction (inverse).
if I set the new Vector3 to :
lineRenderer.SetPosition(i, new Vector3(-p.x, 2, -p.y));
The route has the correct direction, but not the right position.
Can you help me please ? If you can make an script example, with just 2 positions (2 vector2 with Lon et La) for the line renderer and draw it at the right place and direction on the tileset map, I would be very happy
Thanks, have a good day/night