I read answers to this kind of problem, and tried to follow the same instructions, but at this point, I don’t know what to do. The raycast hits the player object instead of objects in the Land layer. Could anyone explain to me what is going on?
public class TapToWalk : MonoBehaviour
{
private bool grounded = false;
public LayerMask groundMask;
void FixedUpdate()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1.0f, 1 << groundMask.value);
if (hit)
{
grounded = true;
Debug.Log (hit.collider.gameObject);
}
else
{
grounded = false;
}
}
}