Joseph Scott
Joseph Scott

Reputation: 25

Does not detect when touching the object

Can't detect when I go to the object on the ground. I am sharing information about this situation below.

itemCollector.class

    {
        if (other.transform.tag == "Collectable")
        {
            print("Cmon");
            Debug.Log("Come here");

        }
    }

enter image description here enter image description here

Doesn't write anything in console section

Upvotes: 0

Views: 48

Answers (2)

Dhruv Anand
Dhruv Anand

Reputation: 133

void OnTriggerEnter(Collision other)
{
    if(other.CompareTag("Collectable")
        {
            Debug.Log("Come Here");
        }
}

Try this instead and add the "Collectable" Tag to the object.

Upvotes: 1

I think your bottles need a rigidbody component.

Unity has a docs about it: https://docs.unity3d.com/Manual/CollidersOverview.html

Upvotes: 0

Related Questions