第一个文件,声明枚举类型,分别为均匀变化和加速变化
using UnityEngine;
using System.Collections;
public enum CTRotationType
{
Uniform,
AccelerateUniformly
}
第二个文件:主函数,实现围绕轴变化的两个函数,分别为均匀变化和加速变化
using UnityEngine;
using System.Collections;
public class CTRotation : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (isRotating)
{
executeRotate();
}
}
bool isRotating = false;
Quaternion definedRotation = new Quaternion(0, 0, 0,0);
Vector3 rotateVector = new Vector3(1,0,0);
float rotateVelocity = 0;
float accelerateDuration = 0;
float leftDuration = 0;
float rotateDuration = 0;
int rotateAxis = 0;
float angleRange = 0;
float deltaRotate = 0;//0;
// acceleration when it is in the accelerating process.
float rotateAcceleration = 0;