<?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 Rotate with Camera Rotate to Compass]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1063</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1063&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Smooth Rotate with Camera Rotate to Compass.]]></description>
		<lastBuildDate>Fri, 25 Oct 2024 11:58:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9683#p9683</link>
			<description><![CDATA[<p>Unfortunately, I didn&#039;t understand your description of the problem.<br />Try to explain it in more detail.<br />And I think a small video in this case will help a lot to explain it.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 25 Oct 2024 11:58:23 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9683#p9683</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9682#p9682</link>
			<description><![CDATA[<p>I have another problem&nbsp; <br />The orientation of the map is nut suitable some times when I drive the market set correctly and the map is OK when I make any round the map begin to be not&nbsp; up and down</p>]]></description>
			<author><![CDATA[null@example.com (tamim.ali.zoabi)]]></author>
			<pubDate>Fri, 25 Oct 2024 11:53:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9682#p9682</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9681#p9681</link>
			<description><![CDATA[<p>Hi. <br />1. An example of how to improve this is attached.<br />2. This is because when you use two fingers, Camera Orbit expects that you may want to rotate the map.<br />To disable this, use Camera Orbit / Lock Pan - ON, Lock Tilt - ON.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 25 Oct 2024 11:27:26 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9681#p9681</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9680#p9680</link>
			<description><![CDATA[<p>Hi is that two choices scripts and i can use one of them <br />and if yes do i keep the :<br />locationService.OnCompassChanged += OnCompassChanged;</p><p>cause i used cameraOrbit but the rotation is kind of glitchy and not smooth . all the time the map trembling when i hold the phone and walk . <br />how to have a smooth Rotation without map vibration.<br />secondly i have a problem : the map rotate but once i use two finger that stretch map imidiatly the map stop rotate with compaschanged , can i disable two finger use .<br />Thanks</p>]]></description>
			<author><![CDATA[null@example.com (tamim.ali.zoabi)]]></author>
			<pubDate>Thu, 24 Oct 2024 19:53:36 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9680#p9680</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4672#p4672</link>
			<description><![CDATA[<p>It is better to create new scripts in order not to lose your changes when updating asset.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 22 Mar 2019 12:32:27 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4672#p4672</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4671#p4671</link>
			<description><![CDATA[<p>Thanks for the swift response.&nbsp; Still learning the appropriate methods in customizing the existing scripts.&nbsp; For the attached solution above am I modifying the existing examples or adding an additional script in addition to the ones I mentioned I am already using?</p>]]></description>
			<author><![CDATA[null@example.com (nmillett)]]></author>
			<pubDate>Fri, 22 Mar 2019 08:37:43 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4671#p4671</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4668#p4668</link>
			<description><![CDATA[<p>Hello.</p><p>1. Use Mathf.Lerp to smooth the rotation of the camera.<br /><a href="https://docs.unity3d.com/ScriptReference/Mathf.Lerp.html">https://docs.unity3d.com/ScriptReferenc … .Lerp.html</a><br />Something like:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class RotateCameraByCompassExample2 : MonoBehaviour
{
    public int speed = 10;

    private OnlineMapsCameraOrbit cameraOrbit;
    private float targetAngle;
    private bool lerpTargetAngle;
    private Vector2 lastRotation;

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

        cameraOrbit = OnlineMapsCameraOrbit.instance;
        lastRotation = cameraOrbit.rotation;
        targetAngle = lastRotation.y;
    }

    private void OnCompassChanged(float f)
    {
        targetAngle = f * 360;
        float angle = cameraOrbit.rotation.y;
        if (angle - targetAngle &gt; 180) targetAngle -= 360;
        else if (targetAngle - angle &gt; 180) targetAngle += 360;

        lerpTargetAngle = true;
    }

    private void Update()
    {
        if (lastRotation != cameraOrbit.rotation) lerpTargetAngle = false;

        if (lerpTargetAngle)
        {
            float newAngle = Mathf.Lerp(lastRotation.y, targetAngle, Time.deltaTime * speed);
            if (Mathf.Abs(newAngle - lastRotation.y) &lt; 0.1)
            {
                lerpTargetAngle = false;
                cameraOrbit.rotation.y = targetAngle;
            }
            else cameraOrbit.rotation.y = newAngle;

            lastRotation = cameraOrbit.rotation;
        }
    }
}</code></pre></div><p>2. Use OnlineMapsCameraOrbit.OnCameraControl to add an offset for the camera.<br />Something like:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

public class SetCameraOffset : MonoBehaviour
{
    public Vector3 centerOffset = new Vector3(0, 0, -300);
    private OnlineMapsCameraOrbit cameraOrbit;
    private OnlineMaps map;
    private OnlineMapsTileSetControl control;

    private void Start()
    {
        map = OnlineMaps.instance;
        control = OnlineMapsTileSetControl.instance;
        cameraOrbit = OnlineMapsCameraOrbit.instance;
        cameraOrbit.OnCameraControl += OnCameraControl;
    }

    private void OnCameraControl()
    {
        Vector2 rotation = OnlineMapsCameraOrbit.instance.rotation;
        float distance = OnlineMapsCameraOrbit.instance.distance;
        float rx = 90 - rotation.x;
        if (rx &gt; 89.9) rx = 89.9f;

        double px = Math.Cos(rx * Mathf.Deg2Rad) * distance;
        double py = Math.Sin(rx * Mathf.Deg2Rad) * distance;
        double pz = Math.Cos(rotation.y * Mathf.Deg2Rad) * px;
        px = Math.Sin(rotation.y * Mathf.Deg2Rad) * px;

        Vector3 targetPosition = map.transform.position;
        Vector3 offset = new Vector3(control.sizeInScene.x / -2, 0, control.sizeInScene.y / 2);
        offset += Quaternion.Euler(0, rotation.y, 0) * centerOffset;

        if (OnlineMapsElevationManagerBase.useElevation)
        {
            double tlx, tly, brx, bry;
            map.GetCorners(out tlx, out tly, out brx, out bry);
            float yScale = OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
            if (cameraOrbit.adjustTo == OnlineMapsCameraAdjust.maxElevationInArea) offset.y = OnlineMapsElevationManagerBase.instance.GetMaxElevation(yScale);
            else offset.y = OnlineMapsElevationManagerBase.GetElevation(targetPosition.x, targetPosition.z, yScale, tlx, tly, brx, bry);
        }

        offset.Scale(map.transform.lossyScale);
        targetPosition += map.transform.rotation * offset;

        Vector3 newPosition = map.transform.rotation * new Vector3((float)px, (float)py, (float)pz) + targetPosition;

        control.activeCamera.transform.position = newPosition;
        control.activeCamera.transform.LookAt(targetPosition);
    }
}</code></pre></div><p>3. Yes, you can try using the touch frameworks.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 21 Mar 2019 10:01:53 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4668#p4668</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4643#p4643</link>
			<description><![CDATA[<p>Also, I&#039;ll note I just purchased and enabled Easy-Touch into my build if this resolves the rotate issue.</p>]]></description>
			<author><![CDATA[null@example.com (nmillett)]]></author>
			<pubDate>Thu, 21 Mar 2019 05:04:20 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4643#p4643</guid>
		</item>
		<item>
			<title><![CDATA[Smooth Rotate with Camera Rotate to Compass]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4642#p4642</link>
			<description><![CDATA[<p>First off ...I want to thank you for all the help and support I have received since my purchase of your Online Maps plug-in.&nbsp; I&#039;ve almost got my setup to the place I need it to be to function for my needs.&nbsp; Few things I still have not worked out yet.</p><p>1.&nbsp; Get camera to rotate smoothly - After enabing the rotate camera by compass script it seems to rotate in clicks or degrees rather then smooth as one would desire.&nbsp; After digging into the script I don&#039;t see any parameters to up the rotate amount to smooth things out.&nbsp; Is it possible to achieve this effect?</p><p>2.&nbsp; Off-Set the marker orbit script - I like how this script focuses on to the location service enabled Prefab but what can I do to off center it while still having it rotate.&nbsp; I&#039;d like it to be in the bottom third of the screen on a mobile device.</p><p>3.&nbsp; &nbsp;Alternatively from using the compass to rotate the camera... what is the best method of rotating the camera by using touch screen methods.&nbsp; I would use this instead of the compass.&nbsp; Just want to try all the functions and determine which is best for my application.&nbsp; </p><p>Thank you!<br />Nate</p>]]></description>
			<author><![CDATA[null@example.com (nmillett)]]></author>
			<pubDate>Thu, 21 Mar 2019 04:38:56 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4642#p4642</guid>
		</item>
	</channel>
</rss>
