Answers for "Rotating object within bounds using gyroscope"
http://answers.unity.com/questions/274497/rotating-object-within-bounds-using-gyroscope.html
The latest answers for the question "Rotating object within bounds using gyroscope"Answer by ScroodgeM
http://answers.unity.com/answers/291593/view.html
after you got gyro.attitude what can't you multiply with device's base rotation to get rotation you need?
then... limiting rotation speed and angle:
<h2>Rotater.cs</h2>
<pre>
using UnityEngine;
public class JustForTestCode : MonoBehaviour
{
public Vector3 Limits = Vector3.one * 50f;
public Vector3 Speeds = Vector3.one * 10f;
public Transform targetRotation;
Vector3 myRotation = Vector3.zero;
void Update()
{
Vector3 targetEuler = targetRotation.rotation.eulerAngles;
for (int i = 0; i <= 2; i++)
{
myRotation[i] = Mathf.Clamp(Mathf.MoveTowards(myRotation[i], Mathf.Repeat(targetEuler[i] + 180f, 360f) - 180f, Time.deltaTime * Speeds[i]), -Limits[i], Limits[i]);
}
transform.rotation = Quaternion.Euler(myRotation);
}
}</pre>Fri, 27 Jul 2012 15:47:20 GMTScroodgeM