I rotate my android phone and it returns me 10 quaternions values. The quaternions values are in x,y,z,i
I hope the unity object in Unity can rotate according to the way how I rotate my android phone. Meaning it can load the quaternions values and rotate accordingly.
How can I do that? Thank you.
Regards, Jimmy
It’s pretty simple.
A Quaternion is a rotation. Transform.rotation is the rotation of your gameObject stored as a Quaternion. You just need to set Transform.rotation to whatever you’re recieving.
Quaternions aren’t that scary. They are really just rotation deltas. Ignore the inner parameters and just treat them like binary blobs.
http://developerblog.myo.com/quaternions/
Is this correct? tqs.
using UnityEngine;
using System.Collections;
public class quartenion : MonoBehaviour {
void Start() {
Quaternion targetRotation = new Quaternion(0.7071F, 0.7071F, 0.0F, 0.0F);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 1);
transform.rotation = new Quaternion(0.5F, 0.5F, -0.5F, 0.5F);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 2);
transform.rotation = new Quaternion(0.0F,0.7071F,-0.7071F, 0.0F);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 3);
transform.rotation = new Quaternion(0.5F, -0.5F, 0.5F, 0.5F);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 4);
}
void Update () {
}
}