<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — How to rotate the camera smoothly by interlocking the compass]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2184&amp;type=atom" />
	<updated>2023-10-18T10:47:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2184</id>
		<entry>
			<title type="html"><![CDATA[Re: How to rotate the camera smoothly by interlocking the compass]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9219#p9219" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2023-10-18T10:47:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9219#p9219</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to rotate the camera smoothly by interlocking the compass]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9218#p9218" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[meetupar123]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2706</uri>
			</author>
			<updated>2023-10-18T08:35:28Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9218#p9218</id>
		</entry>
</feed>
