From 1cd201da607db0757f39c880bc7e4772f5288efb Mon Sep 17 00:00:00 2001 From: yangbear Date: Tue, 30 Jun 2026 00:57:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=BB=E6=8E=89Shoot=E7=9A=84while?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BA=AFWaitForSe?= =?UTF-8?q?conds=E9=81=BF=E5=85=8D=E5=B9=B2=E6=89=B0Animator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户已修复Animator Controller中Shoot循环问题,代码端不再需要每帧SetBool(IsFull,false) --- .../FbxAnimation/Animation/Shoot.anim | 2 +- .../FbxAnimation/Animation/womanIdel.anim | 2 +- Assets/Scenes/main.unity | 153 +++++++++--------- .../Animation/OpeningFlowController.cs | 25 ++- 4 files changed, 91 insertions(+), 91 deletions(-) diff --git a/Assets/Animations/FbxAnimation/Animation/Shoot.anim b/Assets/Animations/FbxAnimation/Animation/Shoot.anim index 647dfdb..5ecd084 100644 --- a/Assets/Animations/FbxAnimation/Animation/Shoot.anim +++ b/Assets/Animations/FbxAnimation/Animation/Shoot.anim @@ -4359,7 +4359,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Animations/FbxAnimation/Animation/womanIdel.anim b/Assets/Animations/FbxAnimation/Animation/womanIdel.anim index c4b4186..f707bf5 100644 --- a/Assets/Animations/FbxAnimation/Animation/womanIdel.anim +++ b/Assets/Animations/FbxAnimation/Animation/womanIdel.anim @@ -8141,7 +8141,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 0 + m_LoopTime: 1 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Scenes/main.unity b/Assets/Scenes/main.unity index 471228f..b2cbebc 100644 --- a/Assets/Scenes/main.unity +++ b/Assets/Scenes/main.unity @@ -7003,79 +7003,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1285985825} m_CullTransparentMesh: 1 ---- !u!1001 &1288780310 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalPosition.x - value: -8.082 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.157 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalPosition.z - value: -8.165 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalRotation.w - value: 0.7071068 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalRotation.x - value: -0.7071068 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: -90 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_Name - value: maninjury - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: de613ce19d622422abbb9e2d63dc7ec6, - type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: de613ce19d622422abbb9e2d63dc7ec6, type: 3} --- !u!1 &1329058527 GameObject: m_ObjectHideFlags: 0 @@ -8187,6 +8114,84 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1381048278 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalPosition.x + value: -8.23723 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalPosition.y + value: 0.123 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalPosition.z + value: -8.286 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalRotation.w + value: 0.7127738 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalRotation.x + value: -0.701394 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: -89.078 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -2946660681007051780, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalPosition.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -2946660681007051780, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_LocalPosition.z + value: -0.836 + objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: 36a64753ffd054a0e98c1efc8590f2a0, + type: 3} + propertyPath: m_Name + value: manInjury + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 36a64753ffd054a0e98c1efc8590f2a0, type: 3} --- !u!1 &1387451484 GameObject: m_ObjectHideFlags: 0 @@ -11841,5 +11846,5 @@ SceneRoots: - {fileID: 1336173886} - {fileID: 1009553495} - {fileID: 19129733} - - {fileID: 1288780310} - {fileID: 119178389} + - {fileID: 1381048278} diff --git a/Assets/Scripts/Animation/OpeningFlowController.cs b/Assets/Scripts/Animation/OpeningFlowController.cs index 7e28c64..113bb08 100644 --- a/Assets/Scripts/Animation/OpeningFlowController.cs +++ b/Assets/Scripts/Animation/OpeningFlowController.cs @@ -94,7 +94,7 @@ public class OpeningFlowController : MonoBehaviour { Debug.Log("=== [OpeningFlow] 片头动画流程开始 ==="); - // 重置参数,让 Animator 默认进入 Idle + // 重置参数,默认 Idle if (_manAnimator != null) { _manAnimator.SetBool("IsStart", false); @@ -106,30 +106,26 @@ public class OpeningFlowController : MonoBehaviour Debug.Log("[OpeningFlow] Step1: man + man2 Idle (1s)"); yield return new WaitForSeconds(1f); - // Step 2: Shoot (3.15s) —— 每帧锁 IsFull=false + // Step 2: Shoot 3.15s Debug.Log("[OpeningFlow] Step2: man Shoot 开始 (3.15s)"); if (_manAnimator != null) { - _manAnimator.SetBool("IsFull", false); _manAnimator.SetBool("IsStart", true); - - float t = 0f; - while (t < 3.15f) - { - t += Time.deltaTime; - _manAnimator.SetBool("IsFull", false); - yield return null; - } + Debug.Log("[OpeningFlow] man IsStart=true, 等待 Shoot 播完"); + } + yield return new WaitForSeconds(3.15f); + if (_manAnimator != null) + { _manAnimator.SetBool("IsStart", false); Debug.Log("[OpeningFlow] Step2: Shoot 结束"); } - // Step 3: 摔倒 —— 直接用 Play 保证播放,不走 Animator 过渡 - Debug.Log("[OpeningFlow] Step3: manfall 开始 (直接 Play)"); + // Step 3: 摔倒 manfull —— 直接 Play 不走过渡 + Debug.Log("[OpeningFlow] Step3: manfall 开始"); if (_manAnimator != null) { _manAnimator.Play("manfull", 0, 0f); - Debug.Log("[OpeningFlow] manfull 已触发, 等待 2.1s"); + Debug.Log("[OpeningFlow] manfull Play 已触发"); } yield return new WaitForSeconds(2.1f); Debug.Log("[OpeningFlow] manfull 播放完成, 停留 2s"); @@ -139,7 +135,6 @@ public class OpeningFlowController : MonoBehaviour Debug.Log("[OpeningFlow] Step4: 黑幕转场开始"); yield return StartCoroutine(FadeBlackScreen(0f, 1f)); - // 隐藏 man 和 man2,显示 woman 和 manInjury if (_manAnimator != null) { _manAnimator.gameObject.SetActive(false); Debug.Log("[OpeningFlow] man 已隐藏"); } if (_man2Object != null) { _man2Object.SetActive(false); Debug.Log("[OpeningFlow] man2 已隐藏"); } if (_womanObject != null) { _womanObject.SetActive(true); Debug.Log("[OpeningFlow] woman 已显示"); }