我的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并将其设置为运动学。我还是不明白,你只说了一件事。另一个呢?