I'm having trouble detecting collision stay/exit.

I’m trying to check when a character has been on or off a platform for a fraction of a second, but I’m running into problems. I think it’s because I’m scaling the object (it squishes/stretches like a spring while the player is building up their jump power) and I think the it’s detecting that’s messing things up, but I’m not sure. What am I doing wrong? Thanks.

var energy: float;
var is_grounded = false;

function Update(){
    if ((Input.GetKey (KeyCode.Space)) && (energy < 1)){
        energy += .01;
       
        transform.localScale.x += .02;
        transform.localScale.y -= .02;       
    }
    if (energy>=1){
        energy = 1;
        var oddeven: boolean = Mathf.FloorToInt(Time.time*7.5) % 2 == 0;
        GetComponent.<Renderer>().enabled = oddeven;
    }

       
    if ((Input.GetKeyUp (KeyCode.Space)) && (is_grounded == true)){
        GetComponent.<Rigidbody2D>().velocity = transform.TransformDirection (Vector3.up * energy * 10);   
        energy = 0;
        Invoke("Grow",.05f);
        GetComponent.<Renderer>().enabled = true;
    }
}

function Grow(){
        transform.localScale.x = 1;
        transform.localScale.y = 3;
}

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

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

Anyone? I’m still stuck.

It could be what you say. When you scale it will scale from the centre so it will go up & down from the centre of the Sprite. This is probably pushing the bottom of the Sprite thru the base & out of the collider. You could try & move the player up at the same rate it is increasing in size or try using on collision stay