Hi guys, okay my problem goes like this i have a damage script for the enemy in javascript then my add gold script is in C#, right now i wanted to make a C# script that able to state if the enemy is dead via gameObject == null then will Player.gold + 1. Is it possible guys? A script that will detect if the object is destroy or no longer there then auto add gold rather than when HP gone only add gold. The below script is not working, anyone have idea?
Enemy.cs
public class enemy : MonoBehaviour {
public GameObject gameObject;
// Use this for initialization
void Start () {
gameObject = GameObject.FindWithTag("Player1");
}
// Update is called once per frame
void Update () {
if (gameObject == null){
Players.gold = Players.gold + 1;
Destroy (gameObject);
}
}
}
↧