Problem with OnTriggerEnter()

Hey guys! I’m making a Doom-style FPS (meaning the Y-axis is locked). Anyways I want the raycasts from shooting to aim up or down based on the enemy the player is looking at. The best workaround i could figure out for this is to attach a trigger box collider to an empty object on the camera that determines the relative Y angle to the enemy when AI enters the box. I’m having trouble getting the OnTriggerEnter() to call (whereas OnTriggerExit() works just fine). Here’s a visual example:
29676-2014-07-23_1542.png

  • There is a collider and rigidbody attached to ALL AI
  • The trigger box attached to the camera is large enough to completely fit the AI
  • The script is attached to the same game object as the trigger
  • They’re all on the same layer (which is set to respect physics on collision with itself)

Here’s some of the script:

private var colliderCount = 0;

function OnTriggerEnter(hit : Collider){
	Debug.Log(colliderCount + "registered");
	if (hit.transform.tag == "AI") {
	colliderCount++;
	Debug.Log(colliderCount);
	}
}

function OnTriggerExit(hit : Collider){
	if (hit.transform.tag == "AI") {
	colliderCount--;
	Debug.Log(colliderCount + "registered");
	}
}

I’d be really happy if someone could help me figure it out (or provide a better workaround than the one I’m using), and I’d be happy to provide pictures of my kitten as a ‘thank you’!

On the collider for the trigger, do you have “Is trigger” ticked?