How can I ignore a platform effector 2D?

Is there any way to ignore a platform effector when an object is passing through it (but not when it’s landing on it)? I’m using this script to detect when an object is touching a platform or not, but it’s (predictably) getting set to true when the player is halfway passing a platform. Any ideas? Thanks

var is_grounded = false;

function OnCollisionStay2D(coll: Collision2D) {
	yield WaitForSeconds (.01);
	if (coll.gameObject.tag == "Platform"){
		CancelInvoke("OnCollisionExit2D");
		is_grounded = true;
	}
}

function OnCollisionExit2D(coll: Collision2D) {
	yield WaitForSeconds (.01);
	if (coll.gameObject.tag == "Platform")
		is_grounded = false;
}

Use Collision2D.enabled to determine if the collision has been disabled or not, in this case by the PlatformEffector2D.

Hi Tofudude624,

I personally don’t use PlatformEffector2d because it would allow my character to go though other colliders next to it. If you only have 1 character you can do what I did which is add a script on your platforms which on Update checks whether the character’s position.y is above them or not. Then they activate their collider only if the character is above. This way you won’t have to worry about OnCollisionStay/Exit2D being called while the character is half-way through the platform.