From 3be7c34642c90bba34543ea1837d0ac6df968d8a Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Mon, 9 Jan 2023 14:49:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BD=B1=E5=AD=90=E7=89=B9?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Main/EffectObj/RoleFastShadow.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Main/EffectObj/RoleFastShadow.cs b/Assets/Scripts/Main/EffectObj/RoleFastShadow.cs index 3c41aa8..875d40e 100644 --- a/Assets/Scripts/Main/EffectObj/RoleFastShadow.cs +++ b/Assets/Scripts/Main/EffectObj/RoleFastShadow.cs @@ -28,6 +28,9 @@ public class RoleFastShadow : MonoBehaviour public int CurrPlayIndex = -1; public float NextPlayTime = 0; + public float SnapStepStartTime = 0; + public Vector3 SnapStepStartPos = Vector3.zero; + public Vector3 NextPos = Vector3.zero; public bool bCanPlay = false; public float StartPlayTime; @@ -110,12 +113,22 @@ public class RoleFastShadow : MonoBehaviour StartPlayTime = 0; CurrPlayIndex = -1; NextPlayTime = 0; - StartPlayTime = Time.time; + StartPlayTime = Time.time; + NextPos = Vector3.zero; } } public void Update() { + if (NextPos != Vector3.zero) + { + if (NextPlayTime - SnapStepStartTime <= 0)//避免分母为0 + return; + + Vector3 stepPr = ( (NextPos - SnapStepStartPos) * (Time.time - SnapStepStartTime) / (NextPlayTime - SnapStepStartTime) ); + transform.position = SnapStepStartPos + stepPr + offset; + } + //未到达播放下一帧的事件 if (!bCanPlay || Time.time < NextPlayTime) return; @@ -129,6 +142,8 @@ public class RoleFastShadow : MonoBehaviour mSpriteRenderer.sprite = snap.mSprite; mBridgeTransfrom.localEulerAngles = snap.BridgeDir; transform.position = snap.Pos + offset; + SnapStepStartPos = transform.position; + SnapStepStartTime = Time.time; //没有后续帧了 if (KeyHistory.Count < CurrPlayIndex + 2) @@ -139,6 +154,7 @@ public class RoleFastShadow : MonoBehaviour else//后续帧 { NextPlayTime = StartPlayTime + KeyHistory[CurrPlayIndex + 1].time; + NextPos = KeyHistory[CurrPlayIndex + 1].Pos; } }