fix: game crashing on entering some levels

This commit is contained in:
KOSMOGOR
2025-05-09 22:31:49 +03:00
parent 9559e9d635
commit 797630e6d6
13 changed files with 193 additions and 26 deletions
+5
View File
@@ -1,3 +1,4 @@
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
@@ -16,6 +17,10 @@ public class MeleeEnemy : Enemy
float currentDelay = 0;
void Start() {
if (!FindFirstObjectByType<NavMeshSurface>()) {
Destroy(gameObject);
return;
}
target = FindFirstObjectByType<Player>();
navMeshAgent = GetComponent<NavMeshAgent>();
patrollingTarget = GetPatrollingTarget();