So I am trying to create a platformer where my cube sprite can jump between different platforms but only when grounded on a platform. I have this working on the first platform but any other platforms I create in the same way it does not. Here is the code I have:
using UnityEngine;
using System.Collections;
public class GroundHitCheck : MonoBehaviour {
bool isGrounded = false;
public Transform GroundCheck1;
public Transform GroundCheck2;
public LayerMask ground_layers;
void FixedUpdate()
{
isGrounded = Physics2D.OverlapArea(GroundCheck1.position,GroundCheck2.position,ground_layers);
Debug.Log("Grounded: "+isGrounded);
}
}
Where am I going wrong?