📜  oncollisionenter 比较标签 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:27.344000             🧑  作者: Mango

代码示例1
private void OnCollisionEnter2D(Collision2D col)
    {
        //for "OnCollision" you need "gameObject" listed not just "CompareTag"
        if (col.gameObject.CompareTag("weapon"))
        {
            Destroy(gameObject);
        }
    }