- Home /
Question by
gss214 · Sep 03, 2015 at 04:45 AM ·
gameobjectlistdestroydestroy objectlife
Deleting objects from list sequence
how can I destroy the object in the scene? I tried this but he is only removing the list.
I want to destroy an object at a time when collide. But I wanted to destroy one by one, like a life system, it collided gone a life, if collided again gone another. sry im new in C#
if (col.gameObject.tag == "pipoca_envenenada") {
Destroy (vidasControl.vidas[1]); // vidasControl.vidas[1] only destroy one object and vidasControl.vidas[] error in console
Destroy (col.gameObject);
}
Comment
Answer by getyour411 · Sep 03, 2015 at 05:22 AM
Is there a reason 'life' is a list? If it was an int you could just do 'life--' Also take a look at List.Remove if you need List: http://www.dotnetperls.com/list-remove