我正在使用一个对撞机脚本来结束游戏,当它击中一个物体。我使用的代码不起作用。请帮帮我!
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);
}
}
}发布于 2016-05-24 13:42:01
我想你把函数名拼错了,应该是OnTriggerEvent.而不是OnTriggerEnter(Collider other)这就是当发生碰撞事件时不调用它的原因。http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html
https://stackoverflow.com/questions/37404902
复制相似问题