unityAnimationCurv曲线变量很好的为我们提供了一个极其方便的数学曲线工具,比如刷怪的时间间隔随着时间的增长,呈现一个多样性的变化,而AnimationCurve便很好的做到了这一点
using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { public AnimationCurve animCurve; public float timer = 0; // Update is called once per frame void Update() { timer += Time.deltaTime; float y = animCurve.Evaluate(timer); transform.position = new Vector3(0, y, 0); } }