I got a problem today, out of no where, the raycast doesn’t seem to work. I debug drawline, it seem to work just fine. The function is also work normally. I can’t figure out why this doesn’t work. Does anyone have a clue? I did both reboot and restart project and this problem still stay. (+photo will show you all the detail of all the scene setup)
For detailing information: I use Unity verison: 2011.3.11f1, 2d urp
.
public class raycast_check : MonoBehaviour
{
public LayerMask Ground_Layer;
public Rigidbody2D rb2d;
private void Start()
{
rb2d.GetComponent<Rigidbody2D>();
}
private void Update()
{
drawLine_();
CheckRayCast();
}
void CheckRayCast()
{
//Debug.Log("raycast func, is working");
if (Physics.Raycast(transform.position, Vector3.down, out RaycastHit hitinfo, 1.5f, Ground_Layer))
{
Debug.Log(hitinfo.transform.name);
}
}
void drawLine_()
{
Debug.DrawRay(transform.position, Vector3.down * 1.5f, Color.red);
}
}
I did talk with 2-3 programmer before coming up with this post they said they has no idea, so I looking forward to a more opening community who know what’s going on with the raycast.


