30 lines
843 B
C#

using UnityEngine;
using NanoBrain;
using CreatureControl;
public class AntennaTouch : MonoBehaviour {
public Neuron receptor;
public Insect insect;
public GameObject hitObject;
protected virtual void Awake() {
this.insect = GetComponentInParent<Insect>();
}
void OnTriggerStay(Collider other) {
this.hitObject = other.gameObject;
Vector3 touchDirection = this.insect.transform.InverseTransformVector(this.transform.forward);
receptor?.SetBias(touchDirection);
}
// Perhaps I can leave this out and use the sleep state?
// Sleep is currently only for clusters..
void OnTriggerExit(Collider other) {
this.hitObject = null;
Vector3 touchDirection = Vector3.zero;
receptor?.SetBias(touchDirection);
}
}