Detect if there's collision from below? (box collider)

Hi, I’m making a sidescroller controller and cant get pass the jumping. I need to know when the player is on ground.
I know I can raycast but it’s not working right with just one raycast, and I can’t figure out working with multiple rays.

After a bit of googling and searching I got this far.

function OnCollisionStay(coll : Collision)
if(coll.contacts.Length > 0)
        var contact = coll.contacts[0];
        if(Vector3.Dot(contact.normal, Vector3.up) > 0.5)
            onGround = true;

But as it works when on ground, I don’t know how to check when its off ground. I tried a bunch different else if’s but none worked.

Any suggestions? Or a better way for doing jumping?

Thank you!

I suggest you to use a Character Controller.

Here look at this link:

It even has the code for the jump that you want.

what i got from the wiki script is you put an --onGround=false-- at the bottum of you`re fixedUpdate function.

that will set grounded to false and will stay false unless you`re collision detect function sets it true.