Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的OnTriggerEnter2D不工作-Unity3D_Unity3d_Scripting_Unityscript - Fatal编程技术网

我的OnTriggerEnter2D不工作-Unity3D

我的OnTriggerEnter2D不工作-Unity3D,unity3d,scripting,unityscript,Unity3d,Scripting,Unityscript,我有一个脚本,在玩家进入门户时播放声音: function OnTriggerEnter2D (other : Collider2D) { if(other.name == "Blue Portal") { audio.PlayOneShot(portalSound); score.GetComponent(Score).scoreNumber += 1; Debug.Log("LOL"); } } 它不响应冲突,也不显示Debu

我有一个脚本,在玩家进入门户时播放声音:

function OnTriggerEnter2D (other : Collider2D) {
    if(other.name == "Blue Portal") {
        audio.PlayOneShot(portalSound);
        score.GetComponent(Score).scoreNumber += 1;
        Debug.Log("LOL");
    }
}

它不响应冲突,也不显示Debug.Log。我已选中门户的is触发器框。我什么都试过了,但就是不起作用。任何帮助都将不胜感激。

这可能是由于这些对象上的刚体是如何设置的(或缺少刚体)。检查a以了解详细信息。

首先删除所有碰撞器组件和刚体组件,然后重新实现Rigidbody2D和Boxcollider2D(触发器上带有true复选框)。然后它就会工作。

我以前尝试过添加Rigidbody2d并将其设置为运动学。我还是不明白,你只说了一件事。另一个呢?