# A simple Java script not working.

I built a script for the positioning of items when they appear in front of the player.

#pragma strict

var Y = 0;
var X = 0;
var Z = 0;
var RotateY = 0;
var RotateX = 0;
var RotateZ = 0;

function Start () {

transform.localPosition.y = Y;
transform.localPosition.z = Z;
transform.localPosition.x = X;

transform.localRotation.y = RotateY;
transform.localRotation.x = RotateX;
transform.localRotation.z = RotateZ;

}

It is rather simple, but the rotation isn’t working. I set the RotateX variable to 90 (the rest to zero) and it sets the rotation to x=1.2731 y=180 z=180. Can anyone make it work?

We really should sticky this. Some newbie gets tripped up by this literally every day and posts about it on the forums.

rotation.x is not the same as changing the X value in the inspector. Quaternions have four values (wxyz). The XYZ values in the inspector modify the Euler angles. the WXYZ values have no superficial relationship to the XYZ values of the Euler angles. For further reading, read up on the Quaternion class and specifically about Euler angles. To learn why this seemingly silly, confusing double standard is used, watch this video. (Euler angles are intuitive for humans to modify, but AWFUL for anything that moves from one rotation to another.)

Use localRotation.eulerAngles.

``````transform.localRotation.eulerAngles = new Vector3(RotateX, RotateY, RotateZ);
``````

Thank You