Hi all, I want to make camera look script for my scene. Camera is child of GO in scene, and I want to rotate this GO via accelerometer in X, Y axes, with circle clamp.
Here is what I’m using so far, its seems to work, but object rotates jerky
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
public float cameraMovementSpeed = 5;
public float Radius = 5;
Vector2 rotation;
void Update() {
rotation = new Vector2(-Input.acceleration.y * cameraMovementSpeed, Input.acceleration.x * cameraMovementSpeed);
Vector2 clampPos = Vector2.ClampMagnitude(rotation, Radius);
transform.rotation = Quaternion.Euler(clampPos.x, clampPos.y, 0.0f);
}
}