Delayed Destroy Clone Not Working

I’m relatively new to Unity, and my shooting script is not working. I’m planning to shoot (instantiate a sphere) then destroy the sphere 5 seconds later. Without the following script, I can shoot, but the spheres will stay on screen. With it, or the Destroy(gameObject, float) on the instantiated sphere, the sphere is destroyed as soon as it is instantiated. Please help.

Here’s the code:


var OffsetCenter = transform.position + center;
var instancesphere = Instantiate(sphere, OffsetCenter, transform.rotation);
instancesphere.rigidbody.AddForce(transform.forward * sphereforce);

Destroy(instancesphere.gameObject, 5);


Simply add a new Script to the bullet prefab, and write on the Awake function:

Destroy(gameObject, 5); should do what you want…? Greetz, Ky.