赞
踩
using System.Collections; using System.Collections.Generic; using UnityEngine; //简单的ease曲线模拟 //f(s+(e-s)*(E/T)) public class EaseTest : MonoBehaviour { public Vector3 endpos; [Range(0, 10)] public float totaltime; private Vector3 startpos; private float elapsedtime; // Start is called before the first frame update void Start() { startpos = transform.position; } //0 ~ 1 private float coefficient; // Update is called once per frame void Update() { elapsedtime += Time.deltaTime; if (this.transform.position != endpos) { coefficient = elapsedtime / totaltime; if (coefficient >= 1) coefficient = 1; print(coefficient); this.transform.position = startpos + (endpos - startpos) * coefficient; } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。