Tag not working

When I typed other.tag for the collision detector script, I got an error saying Collision 2D does not contain a definition for tag despite the fact I created the tag used in my code.
public class CrashDetector : MonoBehaviour

{

private void OnCollisionEnter2D(Collision2D other) {

    if(other.tag == "Ground")

    {

        Debug.Log("Wipe Out");

    }

}

}

Hi,

Have you already checked the Collision2D class in the API? If not, do that please. The class does not have a tag property but there is something else which you could access. And that “something” has got a tag property.

Did this help you solve the problem? :slight_smile:


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms