diff --git a/Examples/BB2B/BB2B.cs b/Examples/BB2B/BB2B.cs index 815fdb1..4f1c3cf 100644 --- a/Examples/BB2B/BB2B.cs +++ b/Examples/BB2B/BB2B.cs @@ -11,6 +11,7 @@ namespace RoboidControl { public BB2B(Participant owner) : base(owner) { this.name = "BB2B"; + this.SetMotors(new Motor(this), new Motor(this)); this.SetDriveDimensions(0.064f, 0.128f); // Is has a touch sensor at the front left of the roboid diff --git a/Unity/DifferentialDrive.cs b/Unity/DifferentialDrive.cs index 91c0883..a0e4b99 100644 --- a/Unity/DifferentialDrive.cs +++ b/Unity/DifferentialDrive.cs @@ -52,6 +52,14 @@ namespace RoboidControl.Unity { if (coreDrive.wheelRadius <= 0) // || coreDrive.wheelSeparation <= 0) return; + // Destroy any (generic) thing with the same id + if (leftWheel == null) { + Thing[] things = FindObjectsOfType(); + foreach (Thing thing in things) { + if (thing.core.id == coreDrive.leftWheel.id) + Destroy(thing.gameObject); + } + } if (leftWheel == null && coreDrive.leftWheel != null) leftWheel = Wheel.Create(this.transform, coreDrive.leftWheel.id); if (leftWheel != null) { @@ -61,6 +69,14 @@ namespace RoboidControl.Unity { // leftWheelCollider.center = new Vector3(-coreDrive.wheelSeparation / 2, 0, 0); } + // Destroy any (generic) thing with the same id + if (rightWheel == null) { + Thing[] things = FindObjectsOfType(); + foreach (Thing thing in things) { + if (thing.core.id == coreDrive.rightWheel.id) + Destroy(thing.gameObject); + } + } if (rightWheel == null && coreDrive.rightWheel != null) rightWheel = Wheel.Create(this.transform, coreDrive.rightWheel.id); if (rightWheel != null) { diff --git a/Unity/Wheel.cs b/Unity/Wheel.cs index d68b9b6..e40891d 100644 --- a/Unity/Wheel.cs +++ b/Unity/Wheel.cs @@ -23,14 +23,6 @@ namespace RoboidControl.Unity { GameObject gameObj = new(core.name); Wheel component = gameObj.AddComponent(); component.Init(core); - // component.wheelCollider = gameObj.AddComponent(); - // component.wheelCollider.mass = 0.1f; - // component.wheelCollider.suspensionDistance = 0.01f; - // component.wheelCollider.suspensionSpring = new JointSpring { - // spring = 100f, // Very high spring value to make it rigid - // damper = 10f, // Low damping (could be adjusted for slight 'bounciness') - // targetPosition = 0.5f // Neutral position (middle of the suspension travel) - // }; Debug.Log("Create " + core.name); return component; } @@ -61,14 +53,6 @@ namespace RoboidControl.Unity { SphereCollider collider = gameObj.AddComponent(); collider.radius = 0.00001f; collider.material = slidingWheel; - // component.wheelCollider = gameObj.AddComponent(); - // component.wheelCollider.mass = 0.1f; - // component.wheelCollider.suspensionDistance = 0.01f; - // component.wheelCollider.suspensionSpring = new JointSpring { - // spring = 100f, // Very high spring value to make it rigid - // damper = 10f, // Low damping (could be adjusted for slight 'bounciness') - // targetPosition = 0.5f // Neutral position (middle of the suspension travel) - // }; Debug.Log("Create placeholder Wheel "); return component; }