- Home /
Question by
Brokenarrow · May 18, 2014 at 05:10 PM ·
rotationeuleranglesquaternionscopydeformation
Object deforms with rotation
Hi, I am having a problem regarding rotation.
I have an object(Gyro) which rotates. This rotation is based on the movement of an accelerometer.
I'm trying to copy the rotation of this object to other objects. However, when I do this using:
void Start () {
gyroscopeCube = GameObject.Find ("Gyro");
}
void Update () {
transform.eulerAngles = new Vector3(gyroscopeCube.transform.eulerAngles.x, gyroscopeCube.transform.eulerAngles.y, gyroscopeCube.transform.eulerAngles.z);
}
It mimics the rotation perfectly, but it horribly deforms the object. Any ideas what may be causing this?
Comment
Answer by Jeff-Kesselman · May 18, 2014 at 05:21 PM
You are probably getting rotation in X and Z. if your camera if looking down the Z axis (default for 2D) this will cause perspective warping.
Try:
transform.eulerAngles = new Vector3(0, gyroscopeCube.transform.eulerAngles.y, 0);
But I need the X and Z rotation, the object must copy its exact rotation, not just one axis.