Hi !
I have a bullet object (Box) and I have script that when you click on the left mouse button
its create a bullet
var blt : Transform;
blt = Instantiate(bullet,transform.position,transform.rotation);
and I have script on the bullet that destory the bullet …
But the problem is after I shooting some bullets,its give me error because its destory the original bullet too.
tillgone is a variable that’s how ever long you the bullets to stick around
you can edit it in the inspector
Hope this helps, and make this a new script and attach it to the bullet pre-fab( these need to reference from a prefab since if its a game object it will self destruct and then your gun wont be able to generate them anymore)
i’m a noob, but I think this code works for deleting objects from the game after a set time
var tillgone : float =1 ;
Destroy (gameObject, tillgone);
Wait, what you need to do is create a bullet prefab in your assets and then attach the bullet asset to your gun , like you attached your current bullet
its not help.
I have the original bullet in the position of the player.
the problem is that all the bullets (the original bullet and the clones of him) are destroyed,and I dont want
that the original bullet will be destoryed…
The reason original bullet is destroyed is because it is in the scene and the script is run, this destroying it.
One way is like keth suggested to add the reference from inspector, not scene.
Another is to disable the bullet, not sure if that works but I don’t see why not. Could need activation though.