private static void MoveTo(Transform trans, Vector3 start, Vector3 end, BehaviourTimeCallback beh) { if (trans != null) { trans.position = GeoUtils.Interpolation(start, end, beh.Percent); } }
private static void LocalEulerTo(Transform trans, Vector3 start, Vector3 end, BehaviourTimeCallback beh) { if (trans != null) { trans.localEulerAngles = GeoUtils.Interpolation(start, end, beh.Percent); } }
protected override void UpdatePosAndTangent() { mCurFrame++; float len = mPathLengthMoved - GetLength(mCurrentWaypointIndex); float lenTotal = GetLength(mCurrentWaypointIndex + 1) - GetLength(mCurrentWaypointIndex); float u = len / lenTotal; Vector3 start = GetWaypoint(mCurrentWaypointIndex); Vector3 end = GetWaypoint(mCurrentWaypointIndex + 1); Vector3 linePos = (1 - u) * start + u * end; #if UNITY_EDITOR mMovedTime += Time.deltaTime; mMovedLength += (linePos - CurInfo.linePos).magnitude; #endif CurInfo.linePos = linePos; CurInfo.curvePos = linePos; if (CurInfo.isDirChanged) { mLast = CurInfo.curveDir; mNext = (end - start).normalized; mCurFrame = 0; } float pro = mCurFrame * mFrameCountInv; if (pro < 1) { CurInfo.curveDir = GeoUtils.Interpolation(mLast, mNext, pro).normalized; } else { CurInfo.curveDir = mNext; } #if UNITY_EDITOR // 记录曲线点和切向,以及线上点和切向 if (trackPos != null) { trackPos.Add(CurInfo.linePos); trackPos.Add(CurInfo.lineDir); trackPos.Add(CurInfo.curvePos); trackPos.Add(CurInfo.curveDir); } #endif }