So I am trying to make a 2d platformer and I want my enemy AI to jump when there is a wall in front of it. I am trying to use raycasts but they are not working. I have a box collider 2d for the wall. Here is my code:
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.right, 10,
LayerMask.NameToLayer("Wall"));
if (hit)
{
Debug.Log("wall detected");
}
yet I am not getting any messages in the console. could somebody help me?