using System.Collections; using System.Collections.Generic; using UnityEngine; using NaughtyAttributes; using Unity.VisualScripting; using UnityEngine.Events; /// /// /// public class BoatRowController : MonoBehaviour { #region Inspector Fields public Transform m_oarTip; public UnityEvent m_OnRow; #endregion Inspector Fields #region Private Fields private Vector3 m_lastKnownOarPosition; #endregion Private Fields #region Getters #endregion Getters #region MonoBehaviour Functions /// /// OnEnable is called when the object becomes enabled and active. /// private void OnEnable() { } /// /// OnDisable is called when the behaviour becomes disabled. /// private void OnDisable() { } /// /// Update is called once per frame /// private void Update() { } #endregion MonoBehaviour Functions #region Class Functionality private void OnTriggerEnter(Collider other) { OarController oar = other.GetComponentInParent(); if (oar != null) { m_lastKnownOarPosition = m_oarTip.localPosition; } } void OnTriggerStay(Collider other) { OarController oar = other.GetComponentInParent(); if(oar != null) { Vector3 direction = m_lastKnownOarPosition - m_oarTip.localPosition; float directionality = Vector3.Dot(direction,Vector3.forward); if (directionality > 0) { Debug.Log($"Row! ({directionality})"); m_OnRow.Invoke(); } else { Debug.Log($"No Row: {directionality}"); } m_lastKnownOarPosition=m_oarTip.localPosition; } else { Debug.Log($"Not Oar: {other.gameObject}"); } } #endregion Class Functionality #region Editor Functions /// /// Called when the Component is created or Reset from the Inspector /// private void Reset() { //useful for finding components on creation } #endregion Editor Functions }