Rotate Die/Cube on Only 2 Axis

I have a button that toggles how a die rotates. I want to rotate it 90 degrees up or 90 degrees right. As if each click shows a different number. When I go back and forth it starts messing up and rotates the top face instead of rotating correctly.

After a rotation x,y,z get all twisted up.

Any suggestions appreciated!

Vector3 rot = Vector3.zero;

	if (indx == 0)
	    rot.y = 90;
	else if (indx == 1)
	{
	    rot.z = 90;
	}

	transform.Rotate (rot, Space.World);

This example will rotate 90 degrees in one frame around the world Y axis if indx is 0 or rotate 90 degrees around the Z axis if it is 1. You can set indx based on whether you want the die moving left/right or up/down (and add case for -90 of course).

Hi, I apologize for the lack of info. I’ll illustrate with photo enclosed!

When toggle at left is in down position, clicking a die in the panel will rotate the die horz which works as intended:

iTween.RotateBy(dieList[dieNum-1],iTween.Hash(“z”,-.25f,“time”,.3f))

Else it tumbles vertically as shown by die 2 which also works as intended:

iTween.RotateBy(dieList[dieNum-1],iTween.Hash(“y”,.25f,“time”,.3f));

But, when I toggle again and click a die I get the result in die three where it’s now rotating on a third axis.

Anyway, thanks

21421-dice.png