/// <summary> /// Capture Unity's collision event. We use triggers since IsKinematic Rigidbodies don't /// raise collisions... only triggers. /// </summary> protected virtual void OnTriggerEnter(Collider rCollider) { if (rCollider == null) { return; } // Record the collider if (!mTriggeredList.Contains(rCollider)) { mTriggeredList.Add(rCollider); // Set the interactable core on the motion if needed if (!_UseRaycast) { MotionController lMC = rCollider.gameObject.GetComponent <MotionController>(); if (lMC != null) { BasicInteraction lInteractionMotion = lMC.GetMotion <BasicInteraction>(); if (lInteractionMotion != null && !lInteractionMotion.IsActive) { lInteractionMotion.InteractableCore = this; } } } } }
/// <summary> /// Raised when the motion triggers the interactable /// </summary> /// <param name="rMotion">BasicInteraction motion</param> public virtual void OnActivated(BasicInteraction rMotion) { mMotion = rMotion; if (ActivatedEvent != null) { Message lMessage = Message.Allocate(); lMessage.ID = EnumMessageID.MSG_INTERACTION_ACTIVATE; lMessage.Data = this.gameObject; ActivatedEvent.Invoke(lMessage); Message.Release(lMessage); } //IsEnabled = false; //StopFocus(); }
/// <summary> /// Capture Unity's collision event /// </summary> protected virtual void OnTriggerExit(Collider rCollider) { if (mTriggeredList.Contains(rCollider)) { mTriggeredList.Remove(rCollider); // Clear the interactable core on the motion if needed if (!_UseRaycast) { MotionController lMC = rCollider.gameObject.GetComponent <MotionController>(); if (lMC != null) { BasicInteraction lInteractionMotion = lMC.GetMotion <BasicInteraction>(); if (lInteractionMotion != null && !lInteractionMotion.IsActive && lInteractionMotion.Interactable == this.gameObject) { lInteractionMotion.InteractableCore = null; } } } } }