Comments and answers for "Rotating object within bounds using gyroscope"
http://answers.unity.com/questions/274497/rotating-object-within-bounds-using-gyroscope.html
The latest comments and 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 GMTScroodgeMComment by psycohk
http://answers.unity.com/comments/290728/view.html
I am facing the same problem. I ain't good at maths but I think the problem should be around the angle rotate will take the shortest path.
http://answers.unity3d.com/questions/29505/jerky-rotation-when-using-quaternionslerp-on-rotat.html
Please let me know if this help or not.Thu, 26 Jul 2012 02:58:36 GMTpsycohk