Hello, I am just starting out in Unity and UnityScript and am trying to check if my 2D platform sprite is grounded. I am having trouble implementing the code from the 2d tutorial demo and have looked at a number of answers on here but must be doing something wrong as it’s still not working. Here is my code:
private var groundCheck : Transform;
private var isGrounded : boolean;
function Start () {
groundCheck = transform.Find("groundCheck");
}
function Update () {
isGrounded= Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
Debug.Log(isGrounded);
}
It doesn’t matter where my player is, isGrounded always returns False.
All help greatly appreciated