Hello friends,
Sorry for newbie question as I am newbie. I am gonna do this:
void OnTriggerStay2D(Collider2D other)
{
if (GameObject.FindWithTag("Human") )
{
//do something
}
}
but the problem is GameObject.FindWithTag() can`t produce a condition for if. So I need to store it some how. I tested below but as trigger is defined with a collider 2d and I am storing in a gameobject then it can`t work. What is the right data type for that instead GameObject? I tried with string and object too and no one could work. Thanks for any help.
GameObject humanTag;
void Start () {
humanTag = GameObject.FindWithTag("Human");
{
void OnTriggerStay2D(Collider2D other)
{
if (other.tag == humanTag)
{
//do something
}
If it helps the tag I need is in the children of a game object so I can`t directly use the parent tag.
↧