Collision Tags

So I have the following code:

 function OnTriggerEnter (other : Collider) 

{ 
	if (other.gameObject.tag=="GREEN")
		{ 
			greenGemCount+=1; 
		}
}

but my gameObject doesn’t seem to register the collision, even with the “Green” gem having the “GREEN” Tag, however when I comment out the

if (other.gameObject.tag=="GREEN")

it seems to work, yet every “Gem” touched increases the value of greenGemCount. It appears correct? Any help, would be apprecited!

–WHYME

It’s generally advisable to use CompareTag() (see here). For example:

if(other.gameObject.CompareTag("GREEN"))
{
    greenGemCount++;
}

I have found from my own experience that CompareTag is the most reliable way. Also, I’m fairly sure that tags are case sensitve.