raycast 2d
using UnityEngine
public class ExampleClass : MonoBehaviour
{
void FixedUpdate()
{
RaycastHit2D hit;
if (Physics2D.Raycast2D(transform.position, transform.TransformDirection(Vector2.forward), out hit, 10))
{
Debug.Log(hit.gameobject);
}
else
{
Debug.Log("Did not Hit");
}
}
}