Hi,
I’m stuck with a problem. I want to use “OnTriggerEnter” and “OnTriggerExit” to detect the collision between a “CharacterController” and a “BoxCollider”, but I’ve only got the enter event, it seems that “OnTriggerExit” doesn’t work in my script. I don’t know why……![]()
My code is very simple……
using UnityEngine;
using System.Collections;
public class LadderCollider : MonoBehaviour {
public MyPlayer avatar;
void OnTriggerEnter(Collider other)
{
if(other.gameObject.name == "Avatar")
{
Debug.Log("enter");
avatar.flag = true;
}
}
void OnTriggerExit(Collider other)
{
Debug.Log("exit");
if(other.gameObject.name == "Avatar")
{
avatar.flag = false;
}
}