Unity Raycast rotation turns into cone

Viewed 145

So basically I have an object in unity that sends out raycasts in 360 degrees around itself.

This works fine when the object moves around, but the problem occurs when the object is rotated.

Whenever I rotate the object, the 360 degree circle of raycasts turn into a cone and get smaller.

How can I get the raycasts to stay in the same "circle shape" regardless of how the object moves and rotates. Before rotation After rotation

Here is the section of code that does the raycast:

for(float i = 0; i < 360; i++){
                 Debug.DrawRay(this.gameObject.transform.position, Quaternion.Euler(0, i, 0) * this.gameObject.transform.forward * 2, Color.red, 1.0f);
             }
1 Answers
    for (float i = 0; i < 360; i++)
    {
        var currentPointPosition = Quaternion.AngleAxis(i, transform.up) * transform.forward;
        Debug.DrawRay(this.gameObject.transform.position, currentPointPosition, Color.red, 1.0f);
    }

like this?

Related