'Vector3 Rotation on Raycast misaligned?

I am attempting to create a code which sends out raycasts all around an enemy. The enemy can then use this information to move itself away from walls and pits and towards other combatants. The only problem is I am doing this in two Dimensions, and it seems that my rotation for the raycast loop is off, so that only one ray pointing up and right actually detects anything. How do I make it so the ray rotates around the emitter in a flat circle?

    float i = 0f;
    Vector3 change = new Vector2(0, 0);
    while (i <= 360f){
        i += 1f;
        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(i, 90f), awareness); // had to go to project setting and change
                                                                                                  // raycast settings for it to not collide with self
        Debug.Log(hit.collider);
        Color color = new Color(0f, 0f, 1.0f);
        if (hit.point.x != 0f && hit.point.y != 0f)
        {
            Debug.DrawLine(transform.position, hit.point, color, awareness);
        }
    }

The debug is how I know only one ray is actually hitting anything, leading me to believe its rotation is wrong.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source