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"))
|
if (other.CompareTag("NPC"))
|
||||||
{
|
{
|
||||||
other.gameObject.SetActive(false);
|
GameManager.instance.currentNPC = null;
|
||||||
|
NPCSpawn.instance.npcSpawned = false;
|
||||||
|
|
||||||
Destroy(other.gameObject);
|
Destroy(other.gameObject);
|
||||||
|
|
||||||
npcSpawnScript.npcSpawned = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,26 @@ using UnityEngine;
|
||||||
|
|
||||||
public class NPCSpawn : MonoBehaviour
|
public class NPCSpawn : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public static NPCSpawn instance;
|
||||||
|
|
||||||
[SerializeField] private float npcBufferTime;
|
[SerializeField] private float npcBufferTime;
|
||||||
public bool npcSpawned = false;
|
public bool npcSpawned = false;
|
||||||
/*[SerializeField]
|
|
||||||
List<GameObject> NPCs = new List<GameObject>();*/
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
GameObject npc;
|
GameObject npc;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
if (instance ==null)
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (!npcSpawned)
|
if (!npcSpawned)
|
||||||
|
|
Loading…
Add table
Reference in a new issue