Hello guys.
I am having a bit weird issue with unity(or c# :)) while comparing tags.
Here is my code;
My Tags Class;
public class Tags : MonoBehaviour {
public const string player = "Player";
public const string gameController = "GameController";
}
My Detection Class;
public class Detection: MonoBehaviour
{
private GameObject player;
void Awake ()
{
player = GameObject.FindGameObjectWithTag(Tags.player);
}
void OnTriggerStay (Collider other)
{
print(other.gameObject.tag); // prints "Player"
print(player.tag); // prints "Player"
if(other.gameObject.tag == player.tag) {
do something...
}
}
}
Although, it prints both tags as the same, i never get into that if statement.
What am i doing wrong?
Thanks.