예제 #1
0
        /// <summary>
        /// If the collision is with an interactable object that is allowed to interact,
        /// make this object the current focus of the player.
        /// </summary>
        /// <param name="collider"></param>
        public void OnTriggerEnter2D(Collider2D collider)
        {
            var interactable = collider.GetComponent <IInteractable>();

            if (interactable == null || !interactable.IsInteractionAllowed())
            {
                return;
            }

            interactableInFocus?.EndInteract();
            interactableInFocus = interactable;
            interactableInFocus.BeginInteract();
        }