From 3611de5142b9392f4587a670c798fa2ed38432bd Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Mon, 5 Jan 2026 11:12:22 +0100 Subject: [PATCH] Fix roaming boid --- Assets/NanoBrain/LinearAlgebra/src/Angle.cs | 27 ++++++++++++--------- Assets/Scenes/Boids/Prefabs/Boid.prefab | 3 ++- Assets/Scenes/Boids/Scripts/Boid.cs | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Assets/NanoBrain/LinearAlgebra/src/Angle.cs b/Assets/NanoBrain/LinearAlgebra/src/Angle.cs index 694d1b7..d73d257 100644 --- a/Assets/NanoBrain/LinearAlgebra/src/Angle.cs +++ b/Assets/NanoBrain/LinearAlgebra/src/Angle.cs @@ -32,7 +32,6 @@ namespace LinearAlgebra { } return new AngleFloat(radians * Rad2Deg); - } public static AngleFloat Revolutions(float revolutions) { @@ -51,17 +50,11 @@ namespace LinearAlgebra { return new AngleFloat(revolutions * 360); } - public float inDegrees { - get { return this.value; } - } + public readonly float inDegrees => this.value; - public float inRadians { - get { return this.value * Deg2Rad; } - } - - public float inRevolutions { - get { return this.value / 360.0f; } - } + public readonly float inRadians => this.value * Deg2Rad; + + public readonly float inRevolutions => this.value / 360.0f; public static readonly AngleFloat zero = Degrees(0); public static readonly AngleFloat deg90 = Degrees(90); @@ -115,6 +108,18 @@ namespace LinearAlgebra { return a1.value != a2.value; } + public override readonly bool Equals(object obj) { + if (obj is AngleFloat other) { + return this == other; + } + return false; + } + + public override readonly int GetHashCode() { + return this.value.GetHashCode(); + } + + /// /// Tests if the first angle is greater than the second /// diff --git a/Assets/Scenes/Boids/Prefabs/Boid.prefab b/Assets/Scenes/Boids/Prefabs/Boid.prefab index 31be0f5..fc3c83c 100644 --- a/Assets/Scenes/Boids/Prefabs/Boid.prefab +++ b/Assets/Scenes/Boids/Prefabs/Boid.prefab @@ -89,6 +89,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_MaskInteraction: 0 m_AdditionalVertexStreams: {fileID: 0} --- !u!136 &8702527963799169118 CapsuleCollider: @@ -176,4 +177,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent - defaultBrain: {fileID: 11400000, guid: fc1a4800a8c531eb4855b436bc9084ae, type: 2} + defaultBrain: {fileID: 11400000, guid: af8d90b8b4b9dcad7837130c4143d91c, type: 2} diff --git a/Assets/Scenes/Boids/Scripts/Boid.cs b/Assets/Scenes/Boids/Scripts/Boid.cs index 43da333..87e8acd 100644 --- a/Assets/Scenes/Boids/Scripts/Boid.cs +++ b/Assets/Scenes/Boids/Scripts/Boid.cs @@ -43,7 +43,7 @@ public class Boid : MonoBehaviour { //Debug.DrawRay(this.transform.position, this.transform.TransformDirection(localPosition), Color.magenta); int thingId = neighbour.GetInstanceID(); - boidReceptor.ProcessStimulus(thingId, localPosition); + boidReceptor?.ProcessStimulus(thingId, localPosition); } }