Pepa Gazdoš
Pepa Gazdoš

Reputation: 9

Rotation around Y affect another AXIS

today, I have huge problem with rotating camera in unity3d.

This code should rotate camera around Y axis right?

var rotSpeed = 5;

if(Input.GetKey("q")){
    this.transform.Rotate(0, -rotSpeed * Time.deltaTime, 0);
}
if(Input.GetKey("e")){
    this.transform.Rotate(0, rotSpeed * Time.deltaTime, 0);
}

But I is affecting another AXIS too! When I press Q or E, X and Z axis are changing too, but why?

Thank you, for your answers.

Upvotes: 0

Views: 682

Answers (1)

theodox
theodox

Reputation: 12208

Do you see the same behavior with

transform.Rotate(0,  -rotSpeed * Time.deltaTime, 0, Space.World);

and

transform.Rotate(0,  -rotSpeed * Time.deltaTime, 0);

?

Also, are you seeing incorrect movement of the object, or just surprising numbers in the editor with correct behavior?

Upvotes: 1

Related Questions