public class DestroyScript : MonoBehaviour {
public float lifetime = 1.0f;
void Start ()
{
}
void Update () {
}
void Awake ()
{
Destroy (gameObject,lifetime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Enemy")
{
//other.gameObject.GetComponent<>().EnemyCurHealth = EnemyCurHealth - 30;
DestroyObject(other.gameObject);
Destroy(gameObject);
}
}
}
I think the problem is on the “//” line cuz im getting errors all the time and i dont know what it is i need in it. i know i need GetComponent to get the health script (The health is just an int) and after i need an
if(EnemyCurHealth = 0)
{
Destroy(gameObject);
}
But can anyone see what i need to do befor?
EDIT: //other.gameObject.GetComponent().EnemyCurHealth = EnemyCurHealth - 30; as a <>script but it wont show in the question somehow
I have GetComponent<> but it wont show in the question. Dont know how, so thats not the problem
– Wingbeatz