diff --git a/Sensors/TouchSensor.cs b/Sensors/TouchSensor.cs index ac2a660..1553ee8 100644 --- a/Sensors/TouchSensor.cs +++ b/Sensors/TouchSensor.cs @@ -1,7 +1,8 @@ namespace Passer.Control.Core { public class TouchSensor : Thing { - public Thing touchedThing = null; + //public Thing touchedThing = null; + public bool touchedSomething = false; public TouchSensor(bool invokeEvent = true) : base(invokeEvent) { } diff --git a/Unity/TouchSensor.cs b/Unity/TouchSensor.cs index b2aac45..4cf41b8 100644 --- a/Unity/TouchSensor.cs +++ b/Unity/TouchSensor.cs @@ -1,5 +1,4 @@ #if UNITY_5_3_OR_NEWER -using System.Collections; using UnityEngine; namespace Passer.Control.Unity { @@ -14,13 +13,6 @@ namespace Passer.Control.Unity { if (core == null) SetCoreThing(new Core.TouchSensor()); - //StartCoroutine(MeasureDistance()); - } - bool update = false; - - protected override void Update() { - base.Update(); - this.update= false; } public static TouchSensor Create(Core.TouchSensor core) { @@ -30,7 +22,7 @@ namespace Passer.Control.Unity { TouchSensor component = gameObj.AddComponent(); Rigidbody rb = gameObj.AddComponent(); rb.isKinematic = true; - + SphereCollider collider = gameObj.AddComponent(); collider.radius = 0.01F; collider.isTrigger = true; @@ -46,11 +38,16 @@ namespace Passer.Control.Unity { } private void OnTriggerEnter(Collider other) { - Debug.Log("Touch!"); - this.coreSensor.touchedThing = other.transform.GetComponentInParent().core; + if (other.isTrigger) + return; + + this.coreSensor.touchedSomething = true; } private void OnTriggerExit(Collider other) { - this.coreSensor.touchedThing = null; + if (other.isTrigger) + return; + + this.coreSensor.touchedSomething = false; } } }