- Home /
Question by
Sixtoo · Apr 30, 2018 at 10:30 AM ·
camera rotaterotation axisrotatearoundpitchyaw
Trying To Free Rotate Camera Around A Point
Hello, I am trying the make the camera rotate around a point. The "Yaw Controls" works horizontally and the "Pitch Controls" works vertically. But if I try use them both at the same time, to free rotate around a point, the camera starts going crooked.
Vector3 pos = RTSControl.transform.position;
if (Input.GetMouseButton(1))
{
float yaw = Input.GetAxis("Mouse X");
float pitch = Input.GetAxis("Mouse Y");
//Yaw Controls
RTSControl.transform.RotateAround(pos, Vector3.up, yaw * 200 * Time.deltaTime);
//Pitch Controls
if (pitch < 0)
{
RTSControl.transform.RotateAround(pos, new Vector3(1, 0, -1), -pitch * 200 * Time.deltaTime);
}
if (pitch > 0)
{
RTSControl.transform.RotateAround(pos, new Vector3(-1, 0, 1), pitch * 200 * Time.deltaTime);
}
return;
}
I think this could be solved by changing the axis value of the pitch controls, but I'm not sure how to do it. I would really appreciate some help with this.
Comment