So I have this weird issue with my camera where if I look around after moving my player to a new location it causes the camera to revert back to the original look rotation before I started moving. I’m guessing Quaternion.Euler might be an issue?
public void MoveCamera()
{
xDeg += Input.GetAxis("Mouse X") * 100 * 0.02f;
yDeg -= Input.GetAxis("Mouse Y") * 100 * 0.02f;
yDeg = Mathf.Clamp(yDeg, -60, 80);
Quaternion rotation = Quaternion.Euler(yDeg, xDeg, 0);
Vector3 vTargetOffset = new Vector3(0, -1.2f, 0);
this.transform.rotation = rotation;
}
Here’s my newer camera code which fixed the above code issue but the clamp is not working. The above code clamping the camera rotation is working.
public void MoveCamera()
{
float pitch = Mathf.Clamp(Input.GetAxis("Mouse Y") * 100, -60, 80);
float yaw = Input.GetAxis("Mouse X") * 100 * Time.deltaTime;
transform.Rotate(-pitch * Time.deltaTime, 0, 0, Space.Self);
transform.Rotate(0, yaw, 0, Space.World);
}