Unity 碰撞检测

private void OnCollisionEnter(Collision collision)
{

Destroy(collision.collider.gameObject);

}

 碰撞检测代码,物理碰撞代码

第二种检测

private void OnTriggerEnter(Collider other)   检测函数  (其他忽略)
{
if (other.tag=="Player")
{
playergame = other.gameObject;
}
}

这种检测是碰撞体没有碰撞效果的检测方式,同上方检测方法一样

原文地址:https://www.cnblogs.com/suiyi78/p/13210416.html