I want to be able to detect objects of a specific Layer mask within a given radius from my object. I tried using SphereCast with the following code
if (Physics.SphereCast(transform.position,radius,transform.forward,out hit,distance, enemy)) {
Debug.Log("hit");
}
but it only gets triggered when the objects are in line with the direction vector specified in my case transform.forward. why am I having this problem and how can I fix it? btw my game object is a sphere just in case