is it possible to add "Tag" in runtime for instantiated gameobject?

hi everyone,

in my game i'm creating gameobjects using Instantiate method...and my question is it possible to add tags for that instantiated gameobjects.....because i'm creating clone only,thats why i'm getting confuse how to add tag with it in runtime???

thanks in advance dudes..

Yes, but the tag needs to be declared in the Ptoject settings > tags before then can be used.

var go = instantiate(transformPrefab, position, rotation);
go.gameObject.tag="myTag";

You don't add a tag, you change the current tag of the gameObject.

hey guys,

found the answer...

dont add tag when create instantiate...the alternative way is better...you may change the existing tag instead for that...by example consider your prefab tag name as "man"...

assume if you want to instantiate 5 man and tag it as "man1,man2,....man5" means you may do the script like this,

int k =1;
for(int j=1; j<=5; j++)
{
GameObject clone=Instantiate(prefab,someObject.transform.position,Quaternion.identity) as GameObject; 

clone.transform.tag = "man"+k;
k++;
}

its very simple....