From 27506e0bba8615b8a64faf655c3a83ae0900d65d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 15 Sep 2021 13:06:48 +0800 Subject: *mv rootmotion folder --- Assets/Scripts/Unit/RootMotion/RootMotionData.cs | 54 ------------------------ 1 file changed, 54 deletions(-) delete mode 100644 Assets/Scripts/Unit/RootMotion/RootMotionData.cs (limited to 'Assets/Scripts/Unit/RootMotion/RootMotionData.cs') diff --git a/Assets/Scripts/Unit/RootMotion/RootMotionData.cs b/Assets/Scripts/Unit/RootMotion/RootMotionData.cs deleted file mode 100644 index f60689ad..00000000 --- a/Assets/Scripts/Unit/RootMotion/RootMotionData.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[CreateAssetMenu(fileName = "RootMotion Data")] -// 单个动画的root motion -public class RootMotionData : ScriptableObject -{ - public string animationName; - - public int frameCount; - - public List positionList; - - public float animationLength; - - public float fps; - - public Vector3 GetRootMotion(float normalTime) - { - normalTime = Mathf.Clamp(normalTime, 0, 1); - int prevFrame = (int)Mathf.Floor((frameCount - 1) * normalTime) % frameCount; - int nextFrame = (int)Mathf.Ceil((frameCount - 1) * normalTime) % frameCount; - float frameRate = 1 / fps; - float t = (normalTime * animationLength - prevFrame * frameRate) / frameRate; - return Vector3.Lerp(positionList[prevFrame], positionList[nextFrame], t); - } - - /// - /// 返回移动量,加到当前position上 - /// - /// 上一次计算root motion的单位时间 - /// 本次取root motion的时间 - /// - public Vector3 GetRootMotionDistance(float prevTime, float curTime) - { - Vector3 p1 = GetRootMotion(prevTime); - Vector3 p2 = GetRootMotion(curTime); - return p2 - p1; - } - -} - -public static class RootMotionUtility -{ - // zy平面的移动改为xy平面的移动 - public static Vector3 ExchangeXZ(Vector3 dest) - { - float z = dest.z; - dest.z = dest.x; - dest.x = z; - return dest; - } -} -- cgit v1.1-26-g67d0