コード例 #1
0
    private void DOBezierCurve(Transform trans, Vector3[] points, float duration)
    {
        ulong n = (ulong)(points.Length - 1);
        float t = 0;

        poslist = new List <Vector3>();
        var handler = DOTween.To(() => t, dt =>
        {
            t = dt;
            trans.position = MathfUtil.BezierCurve(points, t);
            poslist.Add(trans.position);
        }, 1, duration);

        handler.SetEase(Ease.Linear);
    }
コード例 #2
0
ファイル: DOTweenExpand.cs プロジェクト: manaijin/Creator
        /// <summary>
        /// 对象做贝塞尔曲线运动
        /// </summary>
        /// <param name="trans"></param>
        /// <param name="points"></param>
        /// <param name="duration"></param>
        public static TweenerCore <float, float, FloatOptions> DOBezierCurve(this Transform trans, Vector3[] points, float duration, Action <float> cb = null)
        {
            ulong n       = (ulong)(points.Length - 1);
            float t       = 0;
            var   handler = DOTween.To(() => t, dt =>
            {
                t           = dt;
                Vector3 pos = MathfUtil.BezierCurve(points, t);
                var forward = (pos - trans.position).normalized;
                if (forward != Vector3.zero)
                {
                    trans.forward = forward;
                }
                trans.position = pos;
                cb?.Invoke(dt);
            }, 1, duration);

            handler.SetEase(Ease.Linear);
            return(handler);
        }
コード例 #3
0
ファイル: SphereFlow.cs プロジェクト: manaijin/Creator
 private void Update()
 {
     t += Time.unscaledDeltaTime;
     if (t <= duration)
     {
         Vector3 pos     = MathfUtil.BezierCurve(points, t);
         var     forward = (pos - transform.position).normalized;
         if (forward != Vector3.zero)
         {
             transform.forward = forward;
         }
         transform.position = pos;
         points.Add(transform.position);
     }
     else
     {
         t = 0;
         points.Clear();
         CreateNewTween();
     }
 }