- Home /
rotation x changes all angles?
I tried to change just the x rotation of an object(the head shoult look in the direction, that the camera has) but the y and z angels are also influenced and I dont't know why. Any solutions?
var Arm : Transform;
var Head : Transform; var Kamera : Transform; var Charakter : Transform;
function LateUpdate () { //This here works correct Arm.rotation=Kamera.rotation;
//this here doesn't work :/
Head.rotation.x=Kamera.rotation.x;
}
Answer by efge · Feb 21, 2011 at 12:05 PM
Transform.rotation uses Quaternions.
Use Transform.Rotate instead and set the angles for y and z to zero.
Answer by Jesse Anders · Feb 21, 2011 at 12:05 PM
Transform.rotation is a quaternion, and you generally don't want to modify its elements directly.
Try Transform.eulerAngles instead.
Answer by Jessy · Feb 21, 2011 at 12:04 PM
Unity stores rotations as Quaternions internally. To rotate an object, use Transform.Rotate. Use Transform.eulerAngles for setting the rotation as euler angles.
http://unity3d.com/support/documentation/ScriptReference/Transform-rotation.html