Last active
August 27, 2018 14:49
-
-
Save buijldert/91d6957c6e15b63f1ab8c25805fe9242 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class MouseRotateTransformY : MonoBehaviour | |
{ | |
private float sensitivity; | |
private Vector3 mousePos; | |
private Vector3 mouseOffset; | |
private Vector3 rotation; | |
private void Start () | |
{ | |
sensitivity = 0.4f; | |
rotation = Vector3.zero; | |
} | |
private void OnMouseDown() | |
{ | |
mousePos = Input.mousePosition; | |
} | |
private void OnMouseDrag() | |
{ | |
mouseOffset = Input.mousePosition - mousePos; | |
rotation.y = -(mouseOffset.x + mouseOffset.y) * sensitivity; | |
transform.Rotate(rotation); | |
mousePos = Input.mousePosition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment