Im making an FPS tutorial, and I have everything set up, I just need to destroy a target. I want to make it so that when I shoot it, it catches fire (Done.) and after 10 seconds of being on fire, it disappears.
Here's my code:
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Enemy")
{
col.gameObject.tag = "Dead";
Instantiate(fire, col.transform.position, Quaternion.identity); //Works
EnemyCount = EnemyCount - 1; //Works
Invoke("MyWaitingFunction", 10); //Should move to the bottom after 10 seconds
Destroy(gameObject); //works
}
else
{
Destroy(gameObject); //works
}
}
void MyWaitingFunction() //DOESN'T WORK!
{
Destroy(target.gameObject); //Doesn't work!
}
}
Any Ideas?
↧