I have a player, that contains 3 Trigger Collider 2D…
I use OnTriggerEnter2D() which is okay, except when the triggered GameObject is changed… I mean, the Trigger is on the bottom of the player… if I drop it onto another object it is okay… But when it slide from one object to other, and OnTriggerExit2D is NOT called… It does not works… Is the OnTriggerChange2D() ? Or something similar ?
I made a test scene with a sloping plane, made up of several tiles (each with a BoxCollider2D) and then I had an object roll down this slope. The rolling object had two CircleCollider2D, one so that it should roll along and a second one that was set as a trigger. Then I ran the following script:
using UnityEngine;
using System.Collections;
public class TriggerCheck : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log("Enter name: " + other.gameObject.name);
}
void OnTriggerExit2D(Collider2D other)
{
Debug.Log("Exit name: " + other.gameObject.name);
}
void OnTriggerStay2D(Collider2D other)
{
Debug.Log("Stay name: " + other.gameObject.name);
}
}
I got the expected results…
There have been problems with older versions of Unity and OnTriggerExit2D, so make sure you run a version that is uptodate!
Could you try ontriggerstay2d instead ?