0

我正在使用对撞机脚本在撞到物体时结束游戏。我使用的代码不起作用。请帮忙!

using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

public class Collider : MonoBehaviour {


    void OnTriggerEvent(Collider other){
        Debug.Log (other.tag);
        if (other.tag == "Wall") {
            Debug.Log ("collided");
        //  Application.LoadLevel ("level one");
            SceneManager.LoadScene (2);

        } if (other.tag == "End"){ 
            SceneManager.LoadScene(6);
        }
    }
}
4

1 回答 1

3

我认为您拼错了函数名称,它应该是OnTriggerEnter(Collider other)而不是 OnTrigger Event。这就是发生碰撞事件时不调用它的原因。 http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html

于 2016-05-24T05:42:01.127 回答