Collision with ground

Hello!

I am creating a physics based game, and I would like to create a script, which check when is the player on the ground. I have tried it with triggers. I have a collider at the buttom of the player, and I have tried to use it to detect it.

function OnTriggerStay (other : Collider)
{
	if (other.tag != "Player")
	{
		marbleController.onGround = true;	//Set the onGround to true
	}
}

function OnTriggerLeave (other : Collider)
{
	if (other.tag != "Player")
	{
		marbleController.onGround = false;	//Set the onGround to false
	}
}

However, it isn’t working. Is there any better way to do this without the character controller?

I would raycast from the marble towards the ground to see if it hits the ground. The technique is described here:

http://unity3dtutorial.com/unity-3d-tutorials/how-to-make-character-jump-unity-3-rigidbody-character-controller/

Depending on your game you could consider raycast with a layermask parameter (to improve the efficiency of the raycast).