I have a problem with destroying instances of a prefab.
I have searched the site and both of my solutions come from here but neither work properly. I am new to unity so any help will be greatly appreciated.
first of all the bullets are instantiated like this - this bit works fine
Rigidbody newBullet = Instantiate(bulletPrefab, barrel.position, barrel.rotation) as Rigidbody;
newBullet.velocity = shooterT.forward * shootSpeed;
then in the script that is attached the bullet I have tried two different things’
void Start()
{
Destroy(this, liveTime);
}
Which doesn’t seem to do anything
void Start()
{
Destroy(gameObject, liveTime);
}
Which gives the error “The object of type “Rigidbody” has been destroyed but you are still trying to access it”