24 lines
559 B
C#

using UnityEngine;
namespace NanoBrain.Braitenberg {
public class TouchSensor : Sensor {
public bool touching = false;
protected override float SampleSensor() {
return touching ? 1 : 0;
}
void OnTriggerEnter(Collider other) {
Debug.Log($"{this.name} touch start");
touching = true;
}
void OnTriggerExit(Collider other) {
Debug.Log($"{this.name} touch END");
touching = false;
}
}
}