diff --git a/Boids/Assets/Scripts/Boid.cs b/Boids/Assets/Scripts/Boid.cs index 6da9e05..add2380 100644 --- a/Boids/Assets/Scripts/Boid.cs +++ b/Boids/Assets/Scripts/Boid.cs @@ -231,7 +231,7 @@ public class Boid : MonoBehaviour { // Destroy Line Renderers (and child GameObjects) foreach (Transform child in transform) - Destroy(child.gameObject); + DestroyImmediate(child.gameObject); Array.Clear(_lineRenderers, 0, _lineRenderers.Length); } @@ -265,7 +265,7 @@ public class Boid : MonoBehaviour { if (_parent.enableFOVChecks) { // Set FOV Arc rotation to mimic Boid transform rotation _lineRenderers[2].transform.rotation = transform.rotation; - _lineRenderers[2].transform.Rotate(0, 0, _parent.boidFOV / 2f + 180); + _lineRenderers[2].transform.Rotate(0, 0, _parent.boidFOV / 2f); } } } \ No newline at end of file diff --git a/Boids/Assets/Scripts/ShapeDraw.cs b/Boids/Assets/Scripts/ShapeDraw.cs index b5502f1..9707b03 100644 --- a/Boids/Assets/Scripts/ShapeDraw.cs +++ b/Boids/Assets/Scripts/ShapeDraw.cs @@ -3,7 +3,7 @@ /// /// A simple static utility class that assists with drawing shapes using the LineRenderer class. /// -public class ShapeDraw { +public static class ShapeDraw { public static float CircleWidth = 1f; public static float ArcWidth = 1f; public static int CircleVertexCount = 360; @@ -12,12 +12,12 @@ public class ShapeDraw { /// /// Draw a Arc aimed straight up with a certain angle width and radius. - /// Use to point the Arc at a certain direction. + /// This Arc is not direct at any specific angle and start from 0 degrees and ends at angle degrees. + /// You should rotate the LineRenderer to direct it at a specific point. /// /// The LineRenderer to draw the Arc upon. - /// Angle of the Arc + /// Angle (width) of the Arc /// Radius of the Arc - /// public static void DrawArc(LineRenderer lineRenderer, float angle, float radius) { // Setup LineRenderer properties lineRenderer.useWorldSpace = false; @@ -29,9 +29,9 @@ public class ShapeDraw { var pointCount = ArcVertexCount + 1; var points = new Vector3[pointCount + 2]; + // Generate all points for (int i = 0; i < pointCount; i++) { - // Magic '180 - angle' - var rad = Mathf.Deg2Rad * Mathf.LerpAngle(0, angle, i / (float) pointCount); + var rad = Mathf.Deg2Rad * Mathf.Lerp(0, angle, (float) i / pointCount); points[i + 1] = new Vector3(Mathf.Sin(rad), Mathf.Cos(rad), 0) * radius; } @@ -45,7 +45,8 @@ public class ShapeDraw { /// /// Draw a Circle with a specific radius and number of vertexes (detail level) /// - /// + /// The LineRenderer to draw the Circle upon + /// Radius of the Circle public static void DrawCircle(LineRenderer lineRenderer, float radius) { // Setup LineRenderer properties lineRenderer.useWorldSpace = false; @@ -64,12 +65,4 @@ public class ShapeDraw { // Add points to LineRenderer lineRenderer.SetPositions(points); } - - /// - /// - /// - /// - public static void RotateLineRenderer(LineRenderer lineRenderer) { - - } } \ No newline at end of file