using UnityEngine; namespace NanoBrain.Unity.Braitenberg { /// /// A sensor which can detect contacts with static GameObjects or Rigidbodies /// public class TouchSensor : Sensor { /// /// Is the sensor touching something? /// public bool touching { get; protected set; } /// /// Returns the current touching state /// /// 1.0 when touching something, 0.0 otherwise protected override float SampleSensor() { return touching ? 1 : 0; } private void OnTriggerEnter(Collider other) { //Debug.Log($"{this.name} touch start"); touching = true; } private void OnTriggerExit(Collider other) { //Debug.Log($"{this.name} touch END"); touching = false; } } }