x


Delete multiple clones

hello,

i was create multiple balls with clones, and i want to delete that clones one by one, if i use "Destroy(gameObject)" command that game object was entirely deleting with its clone also, can any one say the ans for it?

more ▼

asked Oct 22 '10 at 10:48 AM

sriram90 gravatar image

sriram90
475 33 37 47

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Actually i have created clone balls using instantiate, and much harder when i'm trying to destroy.

Finally i got the answer for it.here it is,

function Update () 
{
if( transform.position.y-nxtPos.y <= 9.9 && ballcreate == false)
{
offset = Vector3(0,60,0);
clone = Instantiate (Sphere1,transform.position + offset, transform.rotation);
ballcreate = true;
}

}

function FixedUpdate()
{
time = time+ Time.deltaTime;

if(transform.position.y <= 180)
{
Destroy(gameObject);
}

}

it'll destroy your game objects continuously when it reaches certain distance.

thank all.

more ▼

answered Nov 02 '10 at 01:45 PM

sriram90 gravatar image

sriram90
475 33 37 47

(comments are locked)
10|3000 characters needed characters left

we can easily delete multiple clones with simple using "Tags".... first we need to tag all clones using "GameObject.FindGameObjectsWithTag("something")"....

assume tag name : "Lock"

void deleteLocks()
{
   foreach(GameObject gos in GameObject.FindGameObjectsWithTag("Lock"))
   {
      if(gos.name == "Locked(Clone)")
      {
    Destroy(gos);
      }
   }
}

here all the clones with tag name "Lock" will destroy easily........

more ▼

answered Jan 20 '11 at 08:55 AM

sriram90 gravatar image

sriram90
475 33 37 47

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x9

asked: Oct 22 '10 at 10:48 AM

Seen: 1515 times

Last Updated: Dec 22 '10 at 07:29 AM