Help me figure out what’s wrong.
I do a Raycast detection:
private void Check()
{
float high = 1.1f, step = 0.35f;
for (float i = -0.1f; i < high; i += step)
{
RaySidePointStart = transform.up * i + transform.position;
RaycastHit2D RaySide = Physics2D.Raycast(RaySidePointStart, vectorSideRay,rayDistanceSide, LayerWall);
Debug.DrawRay(RaySidePointStart, vectorSideRay * rayDistanceSide, Color.blue);
if (RaySide.collider != null)
{
TouchedWall = true;
Debug.Log("This is WALL!!!");
}
else //if (RaySide.collider == null)
{
TouchedWall = false;
}
}
and this is what happens:
[134843-рис1-2-3.jpg|134843]
Why the flag “TouchedWall” does not work when the top ray does not touch the collider?
@badadam You mean: have I confused the levels? If yes, then not confused. Or I did not understand your question?
– alex174@badadam By the way, Debug.Log prints the message regardless of which ray it touches. And each separately, and all together.
– alex174