<?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 — How to rotate the camera smoothly by interlocking the compass]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2184</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2184&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How to rotate the camera smoothly by interlocking the compass.]]></description>
		<lastBuildDate>Wed, 18 Oct 2023 10:47:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to rotate the camera smoothly by interlocking the compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9219#p9219</link>
			<description><![CDATA[<p>Hello.</p><p>Something like that:<br /></p><div class="codebox"><pre><code>using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class RotateCameraByCompassExample2 : MonoBehaviour
    {
        public float duration = 1;

        private OnlineMapsCameraOrbit cameraOrbit;
        private float fromAngle;
        private float toAngle;
        private float progress = 1;

        private void Start()
        {
            OnlineMapsLocationService.instance.OnCompassChanged += OnCompassChanged;

            cameraOrbit = OnlineMapsCameraOrbit.instance;
        }

        private void OnCompassChanged(float f)
        {
            progress = 0;
            fromAngle = cameraOrbit.rotation.y;
            toAngle = f * 360;
        }

        private void Update()
        {
            if (progress &gt;= 1) return;
            progress += Time.deltaTime / duration;
            
            if (progress &gt; 1) progress = 1;
            
            float angle = Mathf.LerpAngle(fromAngle, toAngle, progress);
            cameraOrbit.rotation = new Vector2(cameraOrbit.rotation.x, angle);
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 18 Oct 2023 10:47:04 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9219#p9219</guid>
		</item>
		<item>
			<title><![CDATA[How to rotate the camera smoothly by interlocking the compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9218#p9218</link>
			<description><![CDATA[<p>We tested it using the &quot;Rotate the camera by compass&quot; example.</p><p>During the test, it was confirmed that the camera was disconnected and rotated.</p><p>Please let me know if there is a way to move the camera smoothly by linking the compass!</p>]]></description>
			<author><![CDATA[null@example.com (meetupar123)]]></author>
			<pubDate>Wed, 18 Oct 2023 08:35:28 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9218#p9218</guid>
		</item>
	</channel>
</rss>
