- Home /
Object Rotating On Z Axis No Matter What
Hi,
I have an empty object in the middle of my scene and the maincamera is a child of it, offset to the side. When I rotate the empty object, the camera will look around my scene. Easy! ... no!
public float RotationSpeed = 15;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate((Input.GetAxis("Mouse Y") * RotationSpeed * Time.deltaTime), (Input.GetAxis("Mouse X") * RotationSpeed * Time.deltaTime), 0, Space.World);
}
}
So the only axis I want to rotate on are X and Y. I want to be able to look side to side, up and down, using my mouse. I set the Z axis to 0.
I tested it, and it worked fine except that my camera was rotating on the Z axis. I tried changing Space.World to Space.Self (I'm very new, just trying anything really) and it stayed the same.
I added a rigidbody and put a constraint on Z's rotation, still the same.
Can anyone help me figure this out? Thanks.
Comment