Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Created August 28, 2016 03:57
Show Gist options
  • Save crowjdh/9977dd906ec3c23c5e4b9203b6151881 to your computer and use it in GitHub Desktop.
Save crowjdh/9977dd906ec3c23c5e4b9203b6151881 to your computer and use it in GitHub Desktop.
Rotate object in Unity
using UnityEngine;
using System;
public class RotateObjectBehaviour : MonoBehaviour {
private float sensitivity = 3f;
private void OnMouseDrag() {
float rotX = Input.GetAxis ("Mouse X") * sensitivity * Mathf.Deg2Rad;
float rotY = Input.GetAxis ("Mouse Y") * sensitivity * Mathf.Deg2Rad;
transform.RotateAround (transform.up, -rotX);
transform.RotateAround (Vector3.right, rotY);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment