using UnityEngine;
using System.Collections;
public class RotateObj : MonoBehaviour
{
public float xSpeed = 120.0f;
public float ySpeed = 120.0f;
public float yMinLimit = -20f;
public float yMaxLimit = 80f;
public float smoothTime = 2f;
float rotationYAxis = 0.0f;
float rotationXAxis = 0.0f;
float velocityX = 0.0f;
float velocityY = 0.0f;
// Use this for initialization
void Start()
{
Vector3 angles = transform.eulerAngles;
rotationYAxis = angles.y;
rotationXAxis = angles.x;
}
void LateUpdate()
{
if (Input.GetMouseButtonDown(0))
{
velocityX = 0;
velocityY = 0;
}
if (Input.GetMouseButton(0))
{
velocityX = -xSpeed * Input.GetAxis("Mouse X");
velocityY = ySpeed * Input.GetAxis("Mouse Y");
代码段-平滑的旋转一个物体
最新推荐文章于 2021-09-26 22:21:24 发布