I have a strange problem. My code checks the value of Vector2
and returns an enum based on that value.
But I noticed that sometimes it gives really strange results, even if Vector2
values are the same few times in a row, it's able to give different results.
protected eMove TranslateGridMove (Vector2 move)
{
if (move.x == 1f)
{
Debug.Log("Executing move " + move);
return eMove.RIGHT;
}
else if (move.x == -1f)
{
Debug.Log("Executing move " + move);
return eMove.LEFT;
}
else if (move.y == 1f)
{
Debug.Log("Executing move " + move);
return eMove.UP;
}
else if (move.y == -1f)
{
Debug.Log("Executing move " + move);
return eMove.DOWN;
}
else
{
Debug.LogWarning("PATH FINDING ERROR: CANNOT EXECUTE MOVE " + move);
return eMove.NONE;
}
}
Results:
Executing move (0.0, -1.0)
and sometimes :
PATH FINDING ERROR: CANNOT EXECUTE MOVE (0.0, -1.0)
Why sometimes it works as expected and sometimes not?