<?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 — Smooth Camera Zoom to Location]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2291</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2291&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Smooth Camera Zoom to Location.]]></description>
		<lastBuildDate>Fri, 12 Jul 2024 11:27:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Smooth Camera Zoom to Location]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9587#p9587</link>
			<description><![CDATA[<p>Thank you very much! Disabling the compression already helped. Will follow your other advics as well.</p>]]></description>
			<author><![CDATA[null@example.com (DDQ)]]></author>
			<pubDate>Fri, 12 Jul 2024 11:27:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9587#p9587</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Camera Zoom to Location]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9586#p9586</link>
			<description><![CDATA[<p>Hi.</p><p>The code is ok. I would move the latitude and longitude in the tile position instead of the coordinates, but that is not related to your problem.</p><p>You can disable texture compression in Tileset / Materials &amp; Shaders / Compress Textures.<br />This will increase memory usage, but at the same time can noticeably increase performance.<br />If necessary, you can change this value dynamically to avoid compressing textures at times when you need performance.<br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsTileSetControl.html#aa97db3502f5874f9e78276d08ac57001.">https://infinity-code.com/doxygen/onlin … 08ac57001.</a></p><p>What else you can do to increase smoothness:<br />When starting an animation, simulate moving along your trajectory with a low FPS (e.g. 10 or 5), without passing values to the map.<br />When zoom changes, create tiles in the visible area so the map will queue them to load.<br />To find the range of tiles in the visible area, convert the coordinates to a tile position, subtract and add half the number of visible tiles (width / 256, height / 256).<br />In this case, to avoid unloading the tiles, you will need to lock them when you create them, and unlock them after the end of the animation.<br />Points of Interest:<br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsControlBase.html#a00e3f3cdcc5df50c056e8f5140fbf650">https://infinity-code.com/doxygen/onlin … 5140fbf650</a><br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsTile.html#af017b50f1581047a1a38e7ba46a509b4">https://infinity-code.com/doxygen/onlin … ba46a509b4</a><br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsTile.html#a560176cfe52242ffeb0c416f6c73d8fc">https://infinity-code.com/doxygen/onlin … 6f6c73d8fc</a><br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsProjection.html#aa4c0dcbd4fd0be9199e712d1845170e0">https://infinity-code.com/doxygen/onlin … d1845170e0</a></p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 12 Jul 2024 11:20:00 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9586#p9586</guid>
		</item>
		<item>
			<title><![CDATA[Smooth Camera Zoom to Location]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9585#p9585</link>
			<description><![CDATA[<p>Hi, I am deeply sorry if this question was already answered, but my search had no results.</p><p>I want to realize a smooth camera movement to a specific location on the map. Below my (maybe hacky) code.</p><div class="codebox"><pre><code>IEnumerator MoveCamera(Vector2 coords, int zoom)
        {     
            float currentZoom = OnlineMaps.instance.zoom;

            double currentLon;
            double currentLat;
            OnlineMaps.instance.GetPosition(out currentLon, out currentLat);

            while (Mathf.Abs((float)currentLon - coords.y) &gt; 0.01f || Mathf.Abs((float)currentLat - coords.x) &gt; 0.01f)
            {
                currentLon = Mathf.Lerp((float)currentLon, coords.y, 0.45f);
                currentLat = Mathf.Lerp((float)currentLat, coords.x, 0.45f);
                currentZoom = Mathf.Lerp((float)currentZoom, zoom, 0.65f);

                OnlineMaps.instance.SetPositionAndZoom(currentLon, currentLat, currentZoom);

                yield return null;
            }

            UnlockCamera();
        }</code></pre></div><p>This works functionality wise exactly as intended, but unfortunately I get huge dropdowns if the zoom level changes during the camera movement. I looked in the profiler and its specifically: OnlineMaps.Update() / Texture2D.Compress, which is skyrocketing if there are changes in zoom level.</p><p>Could you tell me if I use the correct approach to realize this function or if there is any way to improve this bottle-neck.</p><p>Thanks,<br />Danish</p>]]></description>
			<author><![CDATA[null@example.com (DDQ)]]></author>
			<pubDate>Thu, 11 Jul 2024 13:29:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9585#p9585</guid>
		</item>
	</channel>
</rss>
