<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Smooth Camera Zoom to Location]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2291&amp;type=atom" />
	<updated>2024-07-12T11:27:19Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2291</id>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Camera Zoom to Location]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9587#p9587" />
			<content type="html"><![CDATA[<p>Thank you very much! Disabling the compression already helped. Will follow your other advics as well.</p>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2024-07-12T11:27:19Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9587#p9587</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Camera Zoom to Location]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9586#p9586" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2024-07-12T11:20:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9586#p9586</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Smooth Camera Zoom to Location]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9585#p9585" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2024-07-11T13:29:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9585#p9585</id>
		</entry>
</feed>
