Skip to content

Instantly share code, notes, and snippets.

@kazukitanaka0611
Created May 15, 2018 07:12
Show Gist options
  • Save kazukitanaka0611/293ee3893db56993ddf6238300e3da40 to your computer and use it in GitHub Desktop.
Save kazukitanaka0611/293ee3893db56993ddf6238300e3da40 to your computer and use it in GitHub Desktop.
Unity mouse camera rotate
void FixedUpdate ()
{
float X_Rotation = Input.GetAxis("Mouse X");
float Y_Rotation = Input.GetAxis("Mouse Y");
Camera.main.transform.Rotate(0, -X_Rotation, 0);
Camera.main.transform.Rotate(Y_Rotation, 0, 0);
Ray ray = new Ray (Camera.main.transform.position, Camera.main.transform.forward);
Debug.DrawRay(ray.origin, ray.direction * 30f, Color.red);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment