Unity Rotation EulerAngle with Mouse

PHOTO EMBED

Sat Jan 23 2021 14:14:37 GMT+0000 (UTC)

Saved by @cotterdev #c#

void Update()
{
  //Get mouse input
  float mouseX = Input.GetAxis("Mouse X");
  //float mouseY = Input.GetAxis("Mouse Y");

  //Get current rotation
  Vector3 tempEulerAngle = transform.localEulerAngles;

  //Change left right rotation
  tempEulerAngle.y += mouseX * _rotationSpeed * Time.deltaTime;

  //Change up down rotation
  //tempEulerAngle.x += mouseY * _rotationSpeed * Time.deltaTime;
  //This needed to be done on another gameObject child otherwise
  //when we look down we move (because we are a capsule).

  //Rotate
  transform.localEulerAngles = tempEulerAngle;
}
content_copyCOPY