using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mrscroll : MonoBehaviour {
public float rotateSpeed = 100; //设置旋转的速度
public Transform PlayerTrans; //设置空物体的位置
public float maxh = 10; //设置提升的最高高度
public Transform cam;
Vector3 startPoint;
Vector3 endPoint;
void Start () {
PlayerTrans.position = PlayerTrans.position + new Vector3(0, maxh, 0);//提升空物体的位置,后面做旋转范围用}
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(1))
{
startPoint = Input.mousePosition;
}
if (Input.GetMouseButton(1))
{
endPoint = Input.mousePosition;
if (startPoint==endPoint)
{
return;
}
if (endPoint.x-startPoint.x>0)
{
cam.Rotate(Vector3.up);
}
else
{
cam.Rotate(Vector3.down);
}
if (endPoint.y - startPoint.y > 0)
{
cam.Rotate(Vector3.left);
}
else {
cam.Rotate(Vector3.right);
}
startPoint = endPoint;
}
}
}
网友评论