I want to be able to rotate a planet by dragging on the screen. I am already using a script for this however you have to drag on the object rather than anywhere on the screen. In addition to this I am trying to find a way to make it so that after you spin it it keeps on moving for a bit.
Here is the code I am using. Does anyone know how it could be changed to achieve what I want?`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragtoRotate : MonoBehaviour
{
public float rotSpeed = 20;
void OnMouseDrag()
{
float rotX = Input.GetAxis("Mouse X") * rotSpeed * Mathf.Deg2Rad;
float rotY = Input.GetAxis("Mouse Y") * rotSpeed * Mathf.Deg2Rad;
transform.RotateAround(Vector3.up, -rotX);
transform.RotateAround(Vector3.right, rotY);
}
}
↧