using UnityEngine; namespace Unity.MLAgents { public class SensorBehavior : MonoBehaviour { MarathonAgent _marathonAgent; IOnSensorCollision _onSensorCollision; Collider _collider; void Start() { _marathonAgent = GetComponentInParent(); _onSensorCollision = GetComponentInParent(); _collider = GetComponent(); } void OnCollisionEnter(Collision other) { if (_marathonAgent != null) _marathonAgent.SensorCollisionEnter(_collider, other); if (_onSensorCollision != null) { _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); } } void OnCollisionExit(Collision other) { if (_marathonAgent != null) _marathonAgent.SensorCollisionExit(_collider, other); if (_onSensorCollision != null) _onSensorCollision.OnSensorCollisionExit(_collider, other.gameObject); } void OnTriggerEnter(Collider other) { if (_onSensorCollision != null) { _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); } } void OnTriggerExit(Collider other) { if (_onSensorCollision != null) _onSensorCollision.OnSensorCollisionExit(_collider, other.gameObject); } void OnTriggerStay(Collider other) { if (_onSensorCollision != null) _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); } void FootCheck(Collision sensor) { Debug.Log($"{sensor}"); if (sensor.gameObject.name == "right_foot_heal_senor_l" || sensor.gameObject.name == "left_foot_heal_senor_l") { float collision = sensor.relativeVelocity.magnitude; Debug.Log($"{collision}"); } } } }