- Home /
Other
Add Icon and Distance (for LineRenderer) like google map
Hello, I was wondering if it was possible to display a navigation icon for my start and end point on my LineRenderer as Google map? I would like to actually display the distance (which I already have) above my LineRenderer and display the arrival icon as on google. Do you have an idea for this, please?
Here is my application that goes from point A to point B using Linerenderer and passing on '' WayPoint '' objects placed in my streets:
Answer by toddisarockstar · Mar 23, 2019 at 05:09 AM
if you have done all this you should have a list of points you used for the renderer. Ur math should be simple after that:
public Vector3[] points = new Vector3[]{
new Vector3(1,1,0),
new Vector3(5,1,0),
new Vector3(6,2,0),
new Vector3(6,3,0),
new Vector3(9,16,0),
new Vector3(10,20,0),
new Vector3(11,25,0),
};
void Start () {
print ("my start icon is at " + points [0]);
print ("my end icon is at " + points[points.Length-1]);
print ("total distance traveled between points is :"+distancebetweenallpoints(points));
}
float distancebetweenallpoints (Vector3[] v){
float r = 0;
int i = v.Length;
while (i>1) {i--;r+=Vector3.Distance(v[i],v[i-1]);}
return r;}
Hey, thanks for your answer In fact, algorithm level everything is fine, I already have all the information I need. I was just wondering how I can display a speech bubble above my LineRenderer in which I would write the distance for example