This commit is contained in:
2026-06-05 22:34:41 +07:00
parent 91183760fb
commit 67e78d1413
4 changed files with 91 additions and 36 deletions

View File

@@ -5,15 +5,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="f9183c68-daf0-43b8-be4c-fad79983f91b" name="Changes" comment=""> <list default="true" id="f9183c68-daf0-43b8-be4c-fad79983f91b" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Animation/Shooter/Animator/Invector@ShooterMelee.controller" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Animation/Shooter/Animator/Invector@ShooterMelee.controller" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Audio/Basic Locomotion/Mixers/FOR AI GAME.mixer" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Audio/Basic Locomotion/Mixers/FOR AI GAME.mixer" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/AI NPC/AnimatorAI.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/AI NPC/AnimatorAI.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Prefabs/NPC/xNPC.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Prefabs/NPC/xNPC.prefab" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Presets/FOR AI GAME.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Presets/FOR AI GAME.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Cho môn AI/Only AI.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Cho môn AI/Only AI.unity" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/AI NPC/ChatBubble.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/AI NPC/ChatBubble.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/AI NPC/EnemyAI.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/AI NPC/EnemyAI.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/AI NPC/GeminiService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/AI NPC/GeminiService.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Player/CharacterController/Editor/Resources/vEditorStartupPrefs.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Player/CharacterController/Editor/Resources/vEditorStartupPrefs.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/TextMesh Pro/Resources/Fonts &amp; Materials/LiberationSans SDF - Fallback.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/TextMesh Pro/Resources/Fonts &amp; Materials/LiberationSans SDF - Fallback.asset" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Third Parties/TextMesh Pro/Resources/Fonts &amp; Materials/LiberationSans SDF - Fallback.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/TextMesh Pro/Resources/Fonts &amp; Materials/LiberationSans SDF - Fallback.asset" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@@ -108,7 +101,7 @@
<option name="MIXED_MODE_DEBUG" value="0" /> <option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost" useMixedMode="false"> <configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" /> <option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" /> <option name="listenPortForConnections" value="false" />
<option name="pid" /> <option name="pid" />
@@ -119,6 +112,7 @@
<option name="selectedOptions"> <option name="selectedOptions">
<list /> <list />
</option> </option>
<option name="useMixedMode" value="false" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="Attach to" type="UnityDevicePlayer" factoryName="UnityAttachToDevicePlayer"> <configuration name="Attach to" type="UnityDevicePlayer" factoryName="UnityAttachToDevicePlayer">

View File

@@ -14716,7 +14716,10 @@ AnimatorStateMachine:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Base Layer m_Name: Base Layer
m_ChildStates: [] m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 4416801500611958025}
m_Position: {x: -358.64734, y: -43.860413, z: 0}
m_ChildStateMachines: m_ChildStateMachines:
- serializedVersion: 1 - serializedVersion: 1
m_StateMachine: {fileID: 1107191697213795204} m_StateMachine: {fileID: 1107191697213795204}
@@ -36256,6 +36259,32 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1102 &4416801500611958025
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TestRun
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400012, guid: 37c6cfe59f56e8a4799011397a870a8b, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &4602781940129309487 --- !u!1101 &4602781940129309487
AnimatorStateTransition: AnimatorStateTransition:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

View File

@@ -90221,6 +90221,22 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6469822191588635990, guid: 15df559ce497e104a81254e0adf3107e, type: 3}
propertyPath: useSimulation
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6469822191588635990, guid: 15df559ce497e104a81254e0adf3107e, type: 3}
propertyPath: autoCycleSpeed
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6469822191588635990, guid: 15df559ce497e104a81254e0adf3107e, type: 3}
propertyPath: forcePlayState
value: Free Movement
objectReference: {fileID: 0}
- target: {fileID: 6469822191588635990, guid: 15df559ce497e104a81254e0adf3107e, type: 3}
propertyPath: showLayerWeights
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7522161431095319480, guid: 15df559ce497e104a81254e0adf3107e, type: 3} - target: {fileID: 7522161431095319480, guid: 15df559ce497e104a81254e0adf3107e, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: xNPC value: xNPC

View File

@@ -68,6 +68,10 @@ public class AnimatorAI : MonoBehaviour
protected vAnimatorParameter powerCharger; protected vAnimatorParameter powerCharger;
#endregion #endregion
[Header("Nuclear Diagnostic (Siêu chẩn đoán)")]
public string forcePlayState = ""; // Gõ tên State vào đây để ép nó chạy (vd: Idle)
public bool showLayerWeights = false;
protected virtual void Start() protected virtual void Start()
{ {
animator = GetComponentInChildren<Animator>(); animator = GetComponentInChildren<Animator>();
@@ -81,45 +85,57 @@ public class AnimatorAI : MonoBehaviour
return; return;
} }
// CHẨN ĐOÁN SÂU: // Chạy chẩn đoán hạt nhân
if (debugMode) StartCoroutine(DeepDiagnosticRoutine()); StartCoroutine(NuclearDiagnosticRoutine());
InitializeParameters(); InitializeParameters();
} }
private IEnumerator DeepDiagnosticRoutine() private IEnumerator NuclearDiagnosticRoutine()
{ {
while (true) while (true)
{ {
yield return new WaitForSeconds(2f); // Kiểm tra mỗi 2 giây yield return new WaitForSeconds(1f);
if (animator == null) yield break; if (animator == null) yield break;
// 1. Kiểm tra Avatar // 1. Kiểm tra Enabled
if (animator.avatar == null) if (!animator.enabled)
Debug.LogError($"<color=red>[T-POSE ALERT]</color> {animator.gameObject.name} KHÔNG CÓ AVATAR! Đây là lý do bị T-Pose. Hãy kéo Avatar vào component Animator."); Debug.LogError($"<color=red>[NUCLEAR ALERT]</color> Component Animator đang bị TẮT (enabled = false)!");
// 2. Kiểm tra Speed
if (animator.speed <= 0)
Debug.LogWarning($"<color=yellow>[T-POSE ALERT]</color> Tốc độ Animator đang bằng {animator.speed}. Nhân vật sẽ không cử động.");
// 3. Kiểm tra Animation Clips // 2. Kiểm tra Rig Type
var stateInfo = animator.GetCurrentAnimatorStateInfo(0); if (animator.isHuman)
var clipInfo = animator.GetCurrentAnimatorClipInfo(0); Debug.Log($"<color=white>[Rig Info]</color> Rig là Humanoid. Hãy chắc chắn các Animation cũng là Humanoid.");
else
if (clipInfo.Length == 0) Debug.LogWarning($"<color=yellow>[Rig Info]</color> Rig là Generic/Legacy. Nếu bạn dùng Animation Humanoid nó sẽ không chạy.");
// 3. Kiểm tra Layer Weight
if (showLayerWeights)
{ {
Debug.LogError($"<color=red>[T-POSE ALERT]</color> State hiện tại ({stateInfo.fullPathHash}) KHÔNG CÓ Clip animation nào! Hãy kéo file .anim vào ô Motion của State trong Animator Controller."); for (int i = 0; i < animator.layerCount; i++)
} {
Debug.Log($"Layer {i} ({animator.GetLayerName(i)}): Weight = {animator.GetLayerWeight(i)}");
// 4. Kiểm tra Culling }
if (animator.cullingMode == AnimatorCullingMode.CullCompletely)
{
// Đôi khi Unity tự tắt animation nếu camera không nhìn thấy
Debug.Log($"<color=white>[Info]</color> Culling Mode đang là CullCompletely. Nếu nhân vật ở xa có thể sẽ dừng animation.");
} }
if (!useSimulation) yield break; // Nếu không dùng simulation thì chỉ check 1 lần rồi thôi // 4. Ép chạy State nếu có yêu cầu
if (!string.IsNullOrEmpty(forcePlayState))
{
Debug.Log($"<color=magenta>[Nuclear Force]</color> ÉP CHẠY STATE: {forcePlayState}");
animator.Play(forcePlayState);
forcePlayState = ""; // Reset sau khi chạy
}
// 5. Kiểm tra vị trí xương (Nếu T-pose thì thường xương không đổi vị trí)
Vector3 handPos = animator.GetBoneTransform(HumanBodyBones.RightHand) ? animator.GetBoneTransform(HumanBodyBones.RightHand).position : Vector3.zero;
yield return new WaitForSeconds(0.1f);
if (handPos != Vector3.zero && Vector3.Distance(handPos, animator.GetBoneTransform(HumanBodyBones.RightHand).position) < 0.001f && animator.speed > 0)
{
// Nếu xương không nhúc nhích dù tốc độ > 0
Debug.LogWarning($"<color=red>[NUCLEAR ALERT]</color> CẢNH BÁO: Xương nhân vật không nhúc nhích! Có thể do Rig lỗi hoặc bị script khác khóa xương.");
}
if (!useSimulation) yield break;
} }
} }