using UnityEngine;
public class Rotate : MonoBehaviour
{
public float speedX;
public float speedY;
private float mouseX;
private float mouseY;
private float scrollWheel;
private float yCount;
private float lastYCount;
void Update()
{
if (Input.GetMouseButton(0))
{
mouseX = Input.GetAxis("Mouse X");
transform.Rotate(Vector3.up, mouseX * speedX, Space.Self);
mouseY = Input.GetAxis("Mouse Y");
float yValue = mouseY * speedY * Time.deltaTime;
yCount += yValue;
yCount = Mathf.Clamp(yCount, -90, 90);
yValue = yCount - lastYCount;
transform.Rotate(Vector3.right, yValue, Space.World);
lastYCount = yCount;
}
scrollWheel = Input.GetAxis("Mouse ScrollWheel");
if(scrollWheel != 0)
{
transform.localScale += scrollWheel * Vector3.one;
float scale = Mathf.Clamp(transform.localScale.x, 0.5f, 2);
transform.localScale = Vector3.one * scale;
}
}
}