OnTriggerExit happens too soon!

I am working on a 2D platformer, and when the box collider of my rigidbody character inches off the side, the “ontriggerexit” function is switched on, and the character shifts into the jumping pose. What script can I use to tell unity to preform such a command only when ALL of the character’s collision exits the collision it stands on??

here’s a video of what is happening: - YouTube

Here is my ontriggerexit/enter script:

function OnCollisionEnter(theCollision : Collision){

	if(theCollision.gameObject.tag == "floor"){
		isgrounded = true;
	}

}

function OnCollisionExit(theCollision : Collision){

	if(theCollision.gameObject.tag == "floor"){
		isgrounded = false;
	}
}

just so you know, I have this script because if I dont, the character jumps into infinity. I use it so that the game knows when he is not grounded he cannot continue to jump. If you know a way around all this, let me know. Thanks!

EDIT: so I have a platform composed of a few 1 by 1 by 1 cubes. Apparently the on trigger exit function isn’t use to that or something, and thats why my character is acting up. well. that’s a bummer. the same problem doesnt occur on normal, longer platforms. strange…

Trigger exit does only happen when your collider completely leaves. That’s not the problem.

The problem is that you have 3 triggers. Each time you fully leave one of them, an exit happens. In your video, as the guy walks to the center of the platform, just as his back edge leaves the first trigger, trigger#1Exit fires and animates him. Not what you wanted, but following the rules perfectly.

An obvious fix is to use one big trigger.

A variant of sdgd’s comment (this is an old operating system trick) is to have a count of how many triggers you are in. Enter says triggerCount++. Exit says triggerCount–. You are grounded if triggerCount is 0. If the count gets off, the game just breaks, but I think triggerEnter/Exit is reliable enough.

Or just switch to the raycast downward method.