我正在使用碰撞器制作一个触发器来禁用脚本。问题是它完美有效,但在使用OnTriggerExit
时,我不确定如何将Enemy Tag发送给null
。
public Casting stop;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Enemy")
{
Debug.Log ("is working trigger");
stop.GetComponent<Casting> ().enabled = false;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag != "Enemy")
{
Debug.Log ("is ended trigger");
stop.GetComponent<Casting> ().enabled = true;
}
}
}