Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Destroy(this) not working properly

$
0
0
I don't think that my Destroy(this) function is working properly, here's the script using UnityEngine; using System.Collections; public class NpcHandler : MonoBehaviour { public string npcName; public int npcLevel; public int npcExpWorth; public int npcCurrHealth, npcMaxHealth; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(npcCurrHealth < 1) { Destroy(this); } } } Now, once he runs out of health the other scripts can no longer reference from it, although the object stays there and the scripts are still attempting to reference, not sure what's going on here. Yes, the script is attatched directly to the game object.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>