Hi, I have a script that is supposed to change the rigidbody along the X or Y axis depending on what mouse button you press. But the Y axis rotation seems to be in world space and the X axis it seems to be in local space. How do I get the whole thin in world space?
(I need to use rigdbody.MoveRotation and not transform.EulerAngles because of strange collision events.)
Here is part of my script:
if (Input.GetMouseButton (0) && Time.time > nextRot) {
nextRot = Time.time + rotRate;
rotX = rotX + 90;
if (rotX > 315) rotX = 0;
if (rotX >= 225 && rotX < 315) rotX = 270;
if (rotX >= 135 && rotX < 225) rotX = 180;
if (rotX >= 45 && rotX < 135) rotX = 90;
if (rotX >= 0 && rotX < 45) rotX = 0;
Debug.Log ("rotX = " + rotX);
xCanRot = true;
}
else xCanRot = false;
if (Input.GetMouseButton (1) && Time.time > nextRot) {
nextRot = Time.time + rotRate;
rotY = rotY + 90;
if (rotY > 315) rotY = 0;
if (rotY >= 225 && rotY < 315) rotY = 270;
if (rotY >= 135 && rotY < 225) rotY = 180;
if (rotY >= 45 && rotY < 135) rotY = 90;
if (rotY >= 0 && rotY < 45) rotY = 0;
Debug.Log ("rotY = " + rotY);
yCanRot = true;
}
else yCanRot = false;
if (yCanRot || xCanRot) {
blockRotation = Quaternion.Euler (Vector3 (rotX,rotY,0.0));
rigidbody.MoveRotation(blockRotation);
}