Hi all!
I’m trying to build some sort of compass app (android). Simply via a camera oriented to a canvas(with webcamtexture) and the sprites which oriented around my camera( with a degree marks).
Unity 5.3.1f
The image to understand:
When I turn my phone in horizontal projection those degree marks are not turning smoothly. They are quite shaky. The video to understand:
Any ideas why it’s so shaky? And how to fix that?
The code:
using UnityEngine;
using System.Collections;
public class QM_Compass : MonoBehaviour {
private Transform myTransform;
public int facingDir;
public int degreeOffset;
public float test_float;
public Transform scrollBar;
void Awake()
{
Input.compass.enabled = true;
Input.location.Start();
}
void Start ()
{
myTransform = transform;
}
void Update () {
test_float = Input.compass.trueHeading;
if (test_float > 360) test_float = test_float % 360;
transform.eulerAngles = new Vector3(0, test_float, 0);
degreeOffset = facingDir = (int)test_float;
}
}