使用余玄函数实现补间缓动
UnityEngine;
using System.Collections;public class NewBehaviourScript : MonoBehaviour {
private float radian=0;//弧度
public float perradian=0.02f;//每次变化值
public float radius=0.03f;//振幅
private Vector3 oldPos;//原始点// Use this for initialization
void Start () {oldPos = this.transform.position;//物体当前未移动位置赋给oldpos作为原始位置
}
// Update is called once per frame
void Update () {radian += perradian;
float dy = Mathf.Cos (radian)*radius;
transform.position = oldPos + new Vector3 (0, dy, 0);
}
}
- 下一篇:Unity重要的函数
- 上一篇:Unity创建文件、读取文件