<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Use LineRenderer to draw route]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1570</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1570&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Use LineRenderer to draw route.]]></description>
		<lastBuildDate>Wed, 11 Aug 2021 07:10:38 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7639#p7639</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (dheerajtibrewal)]]></author>
			<pubDate>Wed, 11 Aug 2021 07:10:38 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7639#p7639</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=6487#p6487</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Pouki)]]></author>
			<pubDate>Wed, 22 Jul 2020 06:10:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=6487#p6487</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use LineRenderer to draw route]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=6486#p6486</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 21 Jul 2020 23:24:26 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=6486#p6486</guid>
		</item>
		<item>
			<title><![CDATA[Use LineRenderer to draw route]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=6483#p6483</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Pouki)]]></author>
			<pubDate>Tue, 21 Jul 2020 18:33:38 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=6483#p6483</guid>
		</item>
	</channel>
</rss>
