简体   繁体   English

触摸 object 时未检测到

[英]Does not detect when touching the object

Can't detect when I go to the object on the ground.无法检测到我go到object在地面上的时候。 I am sharing information about this situation below.我在下面分享有关这种情况的信息。

itemCollector.class itemCollector.class

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

        }
    }

在此处输入图像描述 在此处输入图像描述

Doesn't write anything in console section不在控制台部分写任何东西

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

Try this instead and add the " Collectable " Tag to the object.试试这个,并将“ Collectable ”标签添加到 object。

I think your bottles need a rigidbody component.我认为你的瓶子需要一个刚体组件。

Unity has a docs about it: https://docs.unity3d.com/Manual/CollidersOverview.html Unity 有一个关于它的文档: https://docs.unity3d.com/Manual/CollidersOverview.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM