How to manage eulerAngles?

I have this script that, with iOS touch, a cube rotates around. In the editor, when I move it the ways I want (up/down & left/right) it deals only with the X & Y axis of the cube rotation.

However, in the app itself, the cube seems to be basing it’s rotation on something other than what I expect, and I’m not sure what it is. During the app, even though I’m only rotating it on the x axis, the cube will show the z axis change substantially. In fact, if I rotate the cube 180 degrees on the y axis, the code will register movement on the x axis.

Is there a way to specify that cubes rotate in a more “world” sense? [The code below doesn’t do any of the rotation – that part is working. The problem is that “goalX” and “goalY”, being 0, 90, 180 or 270, aren’t translating the way I expected them for the final “print” statement.]

if (transform.eulerAngles.x >= 45 && transform.eulerAngles.x < 135 && controllerObject.GetComponent(controller).isHolding && goalX != 90)
{
	goalX = 90;
}
else if (transform.eulerAngles.x >= 135 && transform.eulerAngles.x < 225 && controllerObject.GetComponent(controller).isHolding && goalX != 180)
{ 
	goalX = 180;
}
else if (transform.eulerAngles.x >= 225 && transform.eulerAngles.x < 315 && controllerObject.GetComponent(controller).isHolding && goalX != 270)
{
	goalX = 270;
}
else if ((transform.eulerAngles.x >= 315 || transform.eulerAngles.x < 45) && controllerObject.GetComponent(controller).isHolding && goalX != 0)
{
	goalX = 0;
}
if (transform.eulerAngles.y >= 45 && transform.eulerAngles.y < 135 && controllerObject.GetComponent(controller).isHolding && goalY != 90)
{
	goalY = 90;
}
else if (transform.eulerAngles.y >= 135 && transform.eulerAngles.y < 225 && controllerObject.GetComponent(controller).isHolding && goalY != 180)
{
	goalY = 180;
}
else if (transform.eulerAngles.y >= 225 && transform.eulerAngles.y < 315 && controllerObject.GetComponent(controller).isHolding && goalY != 270)
{
	goalY = 270;
}
else if ((transform.eulerAngles.y >= 315 || transform.eulerAngles.y < 45) && controllerObject.GetComponent(controller).isHolding && goalY != 0)
{
	goalY = 0;
}
if (name == "Puzzle Cube1")
{
	print ("Angles: " + transform.eulerAngles + " Goals: " + goalX + " / " + goalY);
}

I’m afraid I truly do not understand what you’re trying to do … does any of this help

look at your rigidbody. very handily, you can simply constrain motion in a given axis, same for rotation

what you say about “world sense”. are you totally au fey with the difference between eulerAngles and localEulerAngles, check it out.

also if you are using Rotate Documentation/ScriptReference/Transform.Rotate.html check out the final parameter which allows you to set world space V local space

finally RotateAround is incredibly useful

Again I simply don’t get what you’re up to, but some of this may help

Finally I don’t know what a controller or controller object is.