Hello,
I want to cast 4 rays from each side of transform, but it doesn’t work and all 4 drawn lines are pointed to Player (which collided with the transform a frame before that code)
Something is probably written wrong but idk what is happening (I’m trying to pass values in Raycast for origin, direction, and max length. And in DrawLine I’m passing origin and direction)
RaycastHit2D hit1 = Physics2D.Raycast(transform.position, Vector2.up, 1f);
if (hit1.transform.name == "BigBricks")
Destroy(hit1.transform);
RaycastHit2D hit2 = Physics2D.Raycast(transform.position, Vector2.right, 1f);
if (hit2.transform.name == "BigBricks")
Destroy(hit2.transform);
RaycastHit2D hit3 = Physics2D.Raycast(transform.position, -Vector2.up, 1f);
if (hit3.transform.name == "BigBricks")
Destroy(hit3.transform);
RaycastHit2D hit4 = Physics2D.Raycast(transform.position, -Vector2.right, 1f);
if (hit4.transform.name == "BigBricks")
Destroy(hit4.transform);
Debug.DrawLine(transform.position, hit1.transform.position);
Debug.DrawLine(transform.position, hit2.transform.position);
Debug.DrawLine(transform.position, hit3.transform.position);
Debug.DrawLine(transform.position, hit4.transform.position);