using UnityEngine; using System.Collections; public class TestArtMove : MonoBehaviour { /// /// /// private Vector3 start = Vector3.zero; /// /// /// private Vector3 end = Vector3.zero; /// /// /// public void Init(Vector3 _s,Vector3 _e) { this.start = _s; this.end = _e; } /// /// /// void Update() { if (this.start == Vector3.zero || this.end == Vector3.zero) { return; } if (Vector2.Distance(transform.position, new Vector2(this.end.x,this.end.y)) < 0.01f) { return; } //两者中心点 Vector3 center = (this.start + this.end) * 0.5f; center -= new Vector3(0, 1, 0); Vector3 start = this.start - center; Vector3 end = this.end - center; //弧形插值 Vector3 curtPos = Vector3.Slerp(start, end, Time.time); transform.position = new Vector3(curtPos.x, curtPos.y, 0); //transform.position += center; } }