Please help.
I am trying to develop a puzzle game in which you must rotate a cube one face at a time, but I am having a great deal of trouble with the Quartenion.Euler function. It seems that when the Z axis is locally pointing in the direction of Y (i.e. when rotation X equals 90 or 270), attempts to rotate on that Z axis only results in rotations on the Y. :(![]()
I desperately need to be able to rotate the cube to view each and every side. I have tried everything to fix this, but just cannot fathom the reason for it.
a simplified version of my code (which I created to check that I wasn’t going crazy) is:
using UnityEngine;
using System.Collections;
public class cubeRotate2 : MonoBehaviour {
private float mouseShiftX;
private float mouseShiftY;
public float Xdegrees;
// Use this for initialization
void Start () {
Xdegrees = 90.0f;
}
void Update () {
mouseShiftX = Screen.width/2 - Input.mousePosition.x;
mouseShiftY = Screen.height/2 - Input.mousePosition.y;
transform.rotation = Quaternion.Euler(Xdegrees, mouseShiftX, mouseShiftY);
}
}
The other values of X which I have tested (namely 0 and 180) present no such problems, and even the reverse; when the X axis is locally pointing in the direction of Y, presents no such issues. Please Help.