<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Use LineRenderer to draw route]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1570&amp;type=atom" />
	<updated>2021-08-11T07:10:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1570</id>
		<entry>
			<title type="html"><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7639#p7639" />
			<content type="html"><![CDATA[<p>hi, Pouki can u please send whole script, as some part of this script might be missing , nd it causing errors ,it will be really helpful for me ,thank you</p>]]></content>
			<author>
				<name><![CDATA[dheerajtibrewal]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1698</uri>
			</author>
			<updated>2021-08-11T07:10:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7639#p7639</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6487#p6487" />
			<content type="html"><![CDATA[<p>Hi,<br />Thank you very much ! <br />For those who are interest : </p><div class="codebox"><pre><code>void Start()
{
     UpdatePoints();

    OnlineMaps.instance.OnChangeZoom += OnChangeZoomOrPosition;
    OnlineMaps.instance.OnChangePosition += OnChangeZoomOrPosition;
    OnlineMapsTileSetControl.instance.OnMeshUpdated += OnMeshUpdated;
}

private void UpdatePoints()
{
    lineRenderer.positionCount = coords.Count;

    for (int i = 0; i &lt; coords.Count; i++)
    {
         Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPosition(coords[i].x, coords[i].y);
         lineRenderer.SetPosition(i, new Vector3(p.x, p.y, p.z));
    }
         needUpdatePoints = false;           
 }

private void OnMeshUpdated()
{
    if (!needUpdatePoints) return;
    UpdatePoints();
}

private void OnChangeZoomOrPosition()
{
    needUpdatePoints = true;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Pouki]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1348</uri>
			</author>
			<updated>2020-07-22T06:10:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6487#p6487</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6486#p6486" />
			<content type="html"><![CDATA[<p>Hello.</p><p>The problem is that you use GetScreenPosition.<br />In your case, you need to use GetWorldPosition:<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsControlBaseDynamicMesh.html#a72cf71ab8fdc9263d81e986316068362">http://infinity-code.com/doxygen/online … 6316068362</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2020-07-21T23:24:26Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6486#p6486</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Use LineRenderer to draw route]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=6483#p6483" />
			<content type="html"><![CDATA[<p>Hey,<br />For few days, I&#039;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&#039;t found what I was searching for.</p><p>Using this code : <br /></p><div class="codebox"><pre><code>LineRenderer lineRenderer = map.AddComponent&lt;LineRenderer&gt;();
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&lt; coords.Count; i++)
{
    Vector3 p = OnlineMapsTileSetControl.instance.GetScreenPosition(coords[i].x, coords[i].y);
    lineRenderer.SetPosition(i, new Vector3(p.x, 2, p.y));
}               </code></pre></div><p><span class="postimg"><img src="https://image.noelshack.com/fichiers/2020/30/2/1595355699-map-inverse.png" alt="PunBB bbcode map" /></span></p><p><strong>The violet lineRenderer is not at the right position and not in the right direction (inverse).</strong><br />if I set the new Vector3 to :&nbsp; </p><div class="codebox"><pre><code>lineRenderer.SetPosition(i, new Vector3(-p.x, 2, -p.y)); </code></pre></div><p>The route has the correct direction, but not the right position.</p><p>Can you help me please ? <img src="https://forum.infinity-code.com/img/smilies/sad.png" width="15" height="15" alt="sad" /> 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 <img src="https://forum.infinity-code.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /> </p><p>Thanks, have a good day/night</p>]]></content>
			<author>
				<name><![CDATA[Pouki]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1348</uri>
			</author>
			<updated>2020-07-21T18:33:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=6483#p6483</id>
		</entry>
</feed>
