- Home /
Destroy object problem.
In my game, when I try to destroy an enemy (the enemies are all just clones of one enemy type) using the code below, it destroys not only the specific enemy that I shot, it destroys all of the enemies that are in the scene, how can I make this stop happening? Thanks
static var EHP=3;
function Update{
if (EHP==0){Destroy (gameObject,0);};
}
Comment
Best Answer
Answer by · Jan 19, 2011 at 05:44 AM
A static var is global across the whole project, so shooting one of them will affect all 'EHP' variables.
(I'm assu$$anonymous$$g that this script is attached to every enemy)
Your answer
