game: fixed npc despawning logic
This commit is contained in:
parent
dcc84d251e
commit
a01b6778aa
2 changed files with 17 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue