Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        float distance = Vector3.Distance(thisTransf.position, player.position);//获得物品与玩家间的距离

        //进入感应范围
        if (distance <= minDistance)
        {
            if (entered)
            {
                return;
            }
            else
            {
                EnableButton();
                entered = true;
            }
        }
        //走出感应范围
        else
        {
            if (!entered)
            {
                return;
            }
            else
            {
                if (pButton != null)
                {
                    pButton.DestroyButton(2);
                }
                entered = false;
            }
        }
    }