Hello there people, was messing around with some mouse drag rotate scripts and finally got a satisfying control over it. To be more specific I was looking into mousedrag and rotate, however while the script is okay and you can rotate the object I want to limit or set a min/max value on 2 of the 3 axis (xmin=0, xmax=0, zmin=0, zmax=0) and just drag-rotate the object on the Y axis only. I know this must be easy but I’m kinda newbie and couldn’t figure something out. If anyone can help me out it would be really great.
Thanks in advance for your help.
Here is the script I last used (rotating on all 3 axis)
using UnityEngine; using System.Collections;
public class DragRotate : MonoBehaviour {
public float mouseRotateSpeed = 20f;
void OnMouseDrag()
{
transform.rotation = Quaternion.AngleAxis( -Input.GetAxis("Mouse X") * mouseRotateSpeed, Camera.main.transform.up) *
Quaternion.AngleAxis( Input.GetAxis("Mouse Y") * mouseRotateSpeed, Camera.main.transform.right) *
transform.rotation;
}
}