Untitled

mail@pastecode.io avatar
unknown
csharp
2 years ago
885 B
5
Indexable
Never
        public static void DrawCircle(float radius, Vector3 center, Vector3 normal, Vector3 right, int circleResolution) {
            float angleSlice = (360 / (float) circleResolution) * Mathf.Deg2Rad;
            Vector3 side = right.normalized;
            Vector3 up = Vector3.Cross(normal, right).normalized;
            
            List<Vector3> points = new List<Vector3>();

            for (int i = 0; i < circleResolution; i++) {
                Vector3 pos = center;
                pos += radius * Mathf.Sin(i * angleSlice) * side;
                pos += radius * Mathf.Cos(i * angleSlice) * up;
                points.Add(pos);
            }

            for (int i = 0; i < points.Count - 1; i++) {
                Gizmos.DrawLine(points[i], points[i + 1]);
            }

            Gizmos.DrawLine(points[points.Count - 1], points[0]);

        }