Topic: Assign Compass rotation to another GameObject
Hey I see that you have a script that can rotate the camera according to the compass values, but what if I want to rotate another game object that is not the camera according to the accurate compass values? I tried the following based on your code:
public class RotateCameraByCompassExample : MonoBehaviour
{
public GameObject cam2;
private void Start()
{
// Subscribe to compass event
OnlineMapsLocationService.instance.OnCompassChanged += OnCompassChanged;
}
/// <summary>
/// This method is called when the compass value is changed.
/// </summary>
/// <param name="f">New compass value (0-1)</param>
private void OnCompassChanged(float f)
{
// Rotate the camera.
OnlineMapsTileSetControl.instance.cameraRotation.y = f * 360;
Vector3 rot = new Vector3 (0f, f * 360f, 0f);
cam2.transform.eulerAngles = rot;
}
}
The problem is that the rotation of my gameobject is veryyyy jerky. It's unusable, am I doing it wrong?