game: fixed npc despawning logic

This commit is contained in:
kookiekenobi 2025-02-05 02:30:22 +08:00
parent dcc84d251e
commit a01b6778aa
2 changed files with 17 additions and 7 deletions

View file

@ -23,12 +23,10 @@ public class Despawn : MonoBehaviour
{
if (other.CompareTag("NPC"))
{
other.gameObject.SetActive(false);
Destroy(other.gameObject);
GameManager.instance.currentNPC = null;
NPCSpawn.instance.npcSpawned = false;
npcSpawnScript.npcSpawned = false;
Destroy(other.gameObject);
}
}
}

View file

@ -4,14 +4,26 @@ using UnityEngine;
public class NPCSpawn : MonoBehaviour
{
public static NPCSpawn instance;
[SerializeField] private float npcBufferTime;
public bool npcSpawned = false;
/*[SerializeField]
List<GameObject> NPCs = new List<GameObject>();*/
[SerializeField]
GameObject npc;
void Awake()
{
if (instance ==null)
{
instance = this;
}
else
{
Destroy(gameObject);
}
}
void Update()
{
if (!npcSpawned)