I wrote a small script that is supposed to destroy the attached gameobject in 1 second, but it keeps saying there is an error. Here is the error: Assets/DestroyExplosion.js(4,36): BCE0044: expecting :, found ';
Here is the script:
function Start () {
WaitForSeconds (1);
{
Destroy(gameObject);
}
}
Too many brackets.
function Start () {
yield WaitForSeconds (1);
Destroy(gameObject);
}
Consider using an object pool and setting active / inactive instead. Instantiating and destroying 1 second apart every time something explodes will lag your game.
I guess you don’t have to use waitForSeconds function. Instead of that, try to use this one:
Destroy(gameObject, 1f);