Ground Checker

I need a ground checker for my jump mechanic but I have no idea how to do so and I have searched online and it didnt help :c

A code in java would be helpful

var speed :float = 5.0;

function FixedUpdate () {

if (Input.GetKey(KeyCode.Espace)) {
transform.Translate(0,speed * Time.deltatime,0);



Perhaps something like this would work:

var grounded : boolean = false;

function OnCollisionStay2D(collisionInfo : Collision2D){
	for(var contact : ContactPoint2D in collisionInfo.contacts){
		if(contact.normal.y >= 0.9){
			grounded = true;

function OnCollisionExit2D(){
	grounded = false;

and then only allow jumping if ‘grounded’ is true!