ошибки поворота, прицела
This commit is contained in:
1 parent
202a894140
commit
da648df1d9
200 files changed
+31969
-629
No files matched your search
@@ -4,6 +4,7 @@ using UnityEngine.AI;
|
||||
public class BlindMutantAI : MonoBehaviour
|
||||
{
|
||||
private NavMeshAgent agent;
|
||||
private Animator animator;
|
||||
|
||||
[Header("Настройки скорости")]
|
||||
public float walkSpeed = 2f;
|
||||
@@ -30,6 +31,7 @@ public class BlindMutantAI : MonoBehaviour
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
agent.speed = walkSpeed;
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
|
||||
// Автоматически находим игрока на сцене
|
||||
var playerObj = FindAnyObjectByType<PlayerHealth>();
|
||||
@@ -46,6 +48,8 @@ public class BlindMutantAI : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateAnimator();
|
||||
|
||||
// 1. Поведение при активном преследовании игрока
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
@@ -60,6 +64,13 @@ public class BlindMutantAI : MonoBehaviour
|
||||
HandlePatrolAndInvestigation();
|
||||
}
|
||||
|
||||
private void UpdateAnimator()
|
||||
{
|
||||
if (animator == null) return;
|
||||
float currentSpeed = agent != null && agent.enabled ? agent.velocity.magnitude : 0f;
|
||||
animator.SetFloat("Speed", currentSpeed);
|
||||
}
|
||||
|
||||
private void HandlePlayerChaseAndAttack()
|
||||
{
|
||||
if (targetPlayerHealth != null && targetPlayerHealth.IsDead)
|
||||
@@ -94,6 +105,10 @@ public class BlindMutantAI : MonoBehaviour
|
||||
if (Time.time >= nextAttackTime)
|
||||
{
|
||||
nextAttackTime = Time.time + attackCooldown;
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetTrigger("Attack");
|
||||
}
|
||||
if (targetPlayerHealth != null)
|
||||
{
|
||||
targetPlayerHealth.TakeDamage(attackDamage);
|
||||
@@ -193,6 +208,10 @@ public class BlindMutantAI : MonoBehaviour
|
||||
|
||||
public void OnDamagedByPlayer(Transform player)
|
||||
{
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetTrigger("GetHit");
|
||||
}
|
||||
EngagePlayer(player);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user