How to work with tags ?

void OnTriggerEnter2D (Collider2D other )
{

	if (other.gameObject.tag == "red") {
		GetComponent<BoxCollider2D>().isTrigger=true;

		respawn = GameObject.FindWithTag("blue"); 

	} 

	if (other.gameObject.tag == "blue") 
	{

	  }
   }

How can I set the other object with different tag ?

I wanna pass on the red tag and Collide on the blue tag.

Just like the color switch thing :smiley:

Hi, First of all you have to add your custom tags in Unity Editor.

Go to Edits>Project Settings>Tags and Layers, add your custom tags there and then assign those tags to appropriate gameObjects. Once its assigned to any gameObject you will get the above code working. You can also assign the tag dynamically from the script.

Hopefully this will help you…

Best,
Hardik.