Download Project/Assets/ML-Agents/Examples/PushBlock/Scripts/GoalDetectTrigger.cs from ashish2244/ppo-SnowballTarget: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/Project/Assets/ML-Agents/Examples/PushBlock/Scripts/GoalDetectTrigger.cs
- Command line
-
hf download hf://ashish2244/ppo-SnowballTarget/Project/Assets/ML-Agents/Examples/PushBlock/Scripts/GoalDetectTrigger.cs
-
curl -L -o GoalDetectTrigger.cs https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/Project/Assets/ML-Agents/Examples/PushBlock/Scripts/GoalDetectTrigger.cs
1.35 kB
| using UnityEngine; | |
| using UnityEngine.Events; | |
| public class GoalDetectTrigger : MonoBehaviour | |
| { | |
| [] | |
| public string tagToDetect = "goal"; //collider tag to detect | |
| [] | |
| public float GoalValue = 1; | |
| private Collider m_col; | |
| [] | |
| public class TriggerEvent : UnityEvent<Collider, float> | |
| { | |
| } | |
| [] | |
| public TriggerEvent onTriggerEnterEvent = new TriggerEvent(); | |
| public TriggerEvent onTriggerStayEvent = new TriggerEvent(); | |
| public TriggerEvent onTriggerExitEvent = new TriggerEvent(); | |
| private void OnTriggerEnter(Collider col) | |
| { | |
| if (col.CompareTag(tagToDetect)) | |
| { | |
| onTriggerEnterEvent.Invoke(m_col, GoalValue); | |
| } | |
| } | |
| private void OnTriggerStay(Collider col) | |
| { | |
| if (col.CompareTag(tagToDetect)) | |
| { | |
| onTriggerStayEvent.Invoke(m_col, GoalValue); | |
| } | |
| } | |
| private void OnTriggerExit(Collider col) | |
| { | |
| if (col.CompareTag(tagToDetect)) | |
| { | |
| onTriggerExitEvent.Invoke(m_col, GoalValue); | |
| } | |
| } | |
| // Start is called before the first frame update | |
| void Awake() | |
| { | |
| m_col = GetComponent<Collider>(); | |
| } | |
| // Update is called once per frame | |
| void Update() | |
| { | |
| } | |
| } | |