Hello everyone, just would like to know if it’s possible to add a time duration after an object has been created and disappear when time expires? Kinda works like a bullet range.
Instantiate(bullet, playerPos.position, Quaternion.identity);
Hello everyone, just would like to know if it’s possible to add a time duration after an object has been created and disappear when time expires? Kinda works like a bullet range.
Instantiate(bullet, playerPos.position, Quaternion.identity);
You can send the Destory function a second parameter for delay, if that’s what you need.
float delay = 1.0f;
GameObject go = (GameObject)Instantiate(bullet, playerPos.position, Quaternion.identity);
Destroy(go, delay);
or as a one line that i love so much,
Destroy((GameObject)Instantiate(bullet, playerPos.position, Quaternion.identity), 1.0f);
Thanks it works!