- Home /
transition.rotation not working.
Here is my script (the variable will come in to play as I develop more).
#pragma strict
var a;
function OnMouseDown() {
transform.position.x=613;
transform.position.y=18.07;
transform.position.z=583;
transform.rotation.x=359;
transform.rotation.y=283;
transform.rotation.z=364;
var a = 0;
}
In game, I press on the game object and the positioning is perfect, but the rotation is not working. I keep on adjusting the values, but nothing happens.
The fixed values are: 359.6852 = X, 0.001112414 = y, and 180 = z
The object keeps appearing straight upside-down (but is not quite).
Please help, thanks and advance.
Answer by robertbu · Apr 16, 2014 at 03:36 AM
A Transofrm.rotation is a Quaternion...a 4D, non-intuitive construct. The x,y,z, and w components are not angles and have a value between -1 and 1. For what you are doing, you can use transform.eulerAngles, but you will get undesirable results if you attempt to set them independently. Instead you should set them all at once like:
transform.eulerAngles = Vector3(359.0, 283.0, 364.0);
There's another problem (I know).
#pragma strict
var a;
function On$$anonymous$$ouseDown() {
transform.position.x=613;
transform.position.y=19;
transform.position.z=583;
transform.rotation.eulerAngles = Vector3(-27.0, -74.0, 0);
a=0;
}
function OnGUI() {
if (a == 0) {
GUI.Box(Rect(100,100,200,100), "This was brought \ninto your inventory.");`
}
}
The console says "interact.js(13,91): BCE0044: unexpected char: '`'.".
Please help.
You have a back-tick character appended to line 13. Delete the last character on the line, and your code will compile.
Anyway, i deleted it and did it again (just line 13). Works fine. Thanks.
Your answer
