📜  oncollisionenter 已声明但从未使用 - C# 代码示例

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

代码示例1
//The problem is that you need to move this out of a void [e.g. void Start() or void Update()] 

void OnCollisionEnter(Collision collision)
    {
        if (other.gameObject.tag == "Object") 
         {
             Debug.Log ("Collided");
         }
    }

//Also same with OnCollisionEnter2D, OnTriggerEnter and OnTriggerEnter2d