首页 > 解决方案 > 如何在 Unity Mapbox World Scale 中添加碰撞物理?

问题描述

在 World Scale AR 中,我想移动到使用 SpawnOnMap 放置的对象。当我触摸那个物体时,我希望那个物体被抹去。我让 Player 有一个名为 PlayerController 的脚本。我为该对象制作了一个标签,以便当它接触时,它应该破坏或将其设置为活动状态。当我走向物体时,什么也没有发生。我已经尝试过 OnTriggerEnter 和 OnCollisionEnter。Mapbox 提供了某种我缺少的方法吗?

public class PelletCollector : MonoBehaviour
{

    public int count = 0;

    // Start is called before the first frame update
    void Start()
    {

    }

    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag == "Pellet")
        {

            count++;
            Debug.Log("Collected Pellets: " + count);

            other.gameObject.SetActive(false);
            //Destroy(other.gameObject);
        }
    }
}

标签: unity3dmapboxcollision-detection

解决方案


推荐阅读