Question: I have problem with add dynamically `tag` to `gameObejcts` , when I `Instantiate` an `enemy` I add enemy tag using this:

```
GameObject temp = (GameObject)Instantiate(enemy, spwanPosition, spwanRotation);
temp.gameObject.tag = "Enemy";

```

I read this from : [Is it possible create a tag programmatically](http://answers.unity3d.com/questions/33597/is-it-possible-to-create-a-tag-programmatically.html)

but when I try to Destroy this object with specific `explosion` There is no object with `Enemy` tag:

```
void OnTriggerEnter(Collider other)
{
    if (other.tag == "Boundary")
    {
        return;
    }
    if (other.tag == "Enemy")
    {
        Debug.Log("enemy");   # Never printed in console
        Instantiate(enemyExplosion, other.transform.position, other.transform.rotation);
    }
    Instantiate(explosion, this.transform.position, this.transform.rotation);
    Destroy(other.gameObject);
    Destroy(this.gameObject);

```

How can I add a tag dynamically to a `gameObject` that `Instantiate` multiple times?

**Edit**

This is the Picture from Instantiated enemy Object in Paused game , It is so wired , it has `Enemy tag` , But why this didn't work?

[![enter image description here](https://i.stack.imgur.com/XbPiz.jpg)](https://i.stack.imgur.com/XbPiz.jpg)

The problem is when in run-time `Enemy` tag is assigned to objects but when I check `if(other.tag == "Enemy")` this dosen't work!

Answer: 
> 
> I read this from : Is it possible create a tag programmatically
> 
> 
> 

It is **NOT** possible to create a tag during run-time. You can **change** the tag of a GameObject to an **existing** one but you **CANNOT** create a **new** one.

So **before** you **assign** a tag named `Enemy` or `Boundary`, make sure that you have already created such tag in the **Editor** first. It is also **case-sensitive**.

> 
> I have problem with add dynamically tag to gameObejcts , when I
>  Instantiate an enemy I add enemy tag using this:
> 
> 
> 
> ```
> Instantiate(enemy, spwanPosition, spwanRotation);
> enemy.tag = "Enemy";
> 
> ```
> 
> How can I add a tag dynamically to a gameObject that Instantiate
>  multiple times?
> 
> 
> 

That's wrong. What you are doing now is **changing** the tag of the **original** GameObject **NOT** the Instantiated **GameObject**. To **change** the **tag** of the **Instantiated** GameObject, **store** a reference of the **Instantiated** GameObject and then **modify** the **tag**. The code below is what you are looking for.

```
GameObject tempGOB= (GameObject)Instantiate(enemy, spwanPosition, spwanRotation);
tempGOB.tag = "Enemy"; //Change the tag of the Instantiated GameObject instead of the enemy(original object)

```
I suspect that your problem is not the tag, but the collision. Does your enemy object have a collider? Does a simple collision test succeed?

Edit (forget about this):

Actually your problem might be that you shouldn't use `other.tag` but `other.gameObject.tag`.