Merge branch 'main' of https://scove-vault.duckdns.org/scove/HALLUCINATION
This commit is contained in:
@@ -68,6 +68,10 @@ public class AnimatorAI : MonoBehaviour
|
||||
protected vAnimatorParameter powerCharger;
|
||||
#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()
|
||||
{
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
@@ -81,45 +85,57 @@ public class AnimatorAI : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// CHẨN ĐOÁN SÂU:
|
||||
if (debugMode) StartCoroutine(DeepDiagnosticRoutine());
|
||||
// Chạy chẩn đoán hạt nhân
|
||||
StartCoroutine(NuclearDiagnosticRoutine());
|
||||
|
||||
InitializeParameters();
|
||||
}
|
||||
|
||||
private IEnumerator DeepDiagnosticRoutine()
|
||||
private IEnumerator NuclearDiagnosticRoutine()
|
||||
{
|
||||
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;
|
||||
|
||||
// 1. Kiểm tra Avatar
|
||||
if (animator.avatar == null)
|
||||
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.");
|
||||
|
||||
// 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.");
|
||||
// 1. Kiểm tra Enabled
|
||||
if (!animator.enabled)
|
||||
Debug.LogError($"<color=red>[NUCLEAR ALERT]</color> Component Animator đang bị TẮT (enabled = false)!");
|
||||
|
||||
// 3. Kiểm tra Animation Clips
|
||||
var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
||||
var clipInfo = animator.GetCurrentAnimatorClipInfo(0);
|
||||
|
||||
if (clipInfo.Length == 0)
|
||||
// 2. Kiểm tra Rig Type
|
||||
if (animator.isHuman)
|
||||
Debug.Log($"<color=white>[Rig Info]</color> Rig là Humanoid. Hãy chắc chắn các Animation cũng là Humanoid.");
|
||||
else
|
||||
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.");
|
||||
}
|
||||
|
||||
// 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.");
|
||||
for (int i = 0; i < animator.layerCount; i++)
|
||||
{
|
||||
Debug.Log($"Layer {i} ({animator.GetLayerName(i)}): Weight = {animator.GetLayerWeight(i)}");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,66 @@
|
||||
using UnityEngine;
|
||||
using Hallucinate.Audio;
|
||||
using Invector;
|
||||
|
||||
public class LaserProjectile : MonoBehaviour
|
||||
{
|
||||
public float speed = 5f;
|
||||
public float speed = 15f; // Tăng tốc độ đạn để cảm giác mượt hơn
|
||||
public float lifeTime = 5f;
|
||||
public int damageAmount = 10;
|
||||
|
||||
[Header("Audio")]
|
||||
public string hitSound = "Laser_Hit";
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Tự hủy sau một khoảng thời gian nếu không trúng gì
|
||||
Destroy(gameObject, lifeTime);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.position +=
|
||||
transform.forward *
|
||||
speed *
|
||||
Time.deltaTime;
|
||||
// Di chuyển đạn
|
||||
transform.position += transform.forward * speed * Time.deltaTime;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
// Debug: Log tên và tag của bất cứ thứ gì đạn chạm vào
|
||||
Debug.Log($"Laser collided with: {other.name} | Tag: {other.tag} | Layer: {LayerMask.LayerToName(other.gameObject.layer)}");
|
||||
|
||||
// Kiểm tra nếu trúng Player
|
||||
if (other.CompareTag("Player") || other.GetComponentInParent<vIHealthController>() != null)
|
||||
{
|
||||
Debug.Log("Player Hit");
|
||||
var healthController = other.GetComponentInParent<vIHealthController>();
|
||||
|
||||
if (healthController != null)
|
||||
{
|
||||
Debug.Log($"<color=red>HIT PLAYER!</color> Found health controller on {healthController.gameObject.name}. Applying {damageAmount} damage.");
|
||||
var damage = new vDamage(damageAmount);
|
||||
damage.sender = transform;
|
||||
damage.hitPosition = transform.position;
|
||||
healthController.TakeDamage(damage);
|
||||
}
|
||||
|
||||
// Luôn phá hủy đạn khi trúng Player
|
||||
Impact();
|
||||
return;
|
||||
}
|
||||
|
||||
AudioManager.Instance?.Play(hitSound, position: transform.position);
|
||||
|
||||
Destroy(gameObject);
|
||||
// Phá hủy đạn nếu trúng tường, sàn nhà (mọi thứ không phải trigger khác)
|
||||
if (!other.isTrigger)
|
||||
{
|
||||
Debug.Log("Laser hit an obstacle (Wall/Floor).");
|
||||
Impact();
|
||||
}
|
||||
}
|
||||
|
||||
private void Impact()
|
||||
{
|
||||
// Chạy âm thanh
|
||||
AudioManager.Instance?.Play(hitSound, position: transform.position);
|
||||
|
||||
// Phá hủy đạn ngay lập tức
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -318,6 +318,14 @@ namespace Invector.vCharacterController
|
||||
currentStaminaRecoveryDelay = 2f;
|
||||
}
|
||||
|
||||
public override void TakeDamage(vDamage damage)
|
||||
{
|
||||
Debug.Log($"Player TakeDamage called. Damage: {damage.damageValue}. Current Health before: {currentHealth}");
|
||||
base.TakeDamage(damage);
|
||||
Debug.Log($"Player Health after: {currentHealth}");
|
||||
// Additional logic for player-specific damage handling can be added here
|
||||
}
|
||||
|
||||
|
||||
#region Check Action Triggers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user