Extension

Example (inherit from Interactable)

namespace SurvivalTemplatePro
{
    public class InteractableTest : Interactable
    {
        public override void OnInteract(ICharacter character)
        {
            base.OnInteract(character);

            // Do something when a character interacts with this.
            // e.g. press a button
        }

        public override void OnHoverStart(ICharacter character)
        {
            base.OnHoverStart(character);

            // Do something when a character starts looking at this object.
            // e.g. Enable outline effect
        }

        public override void OnHoverEnd(ICharacter character)
        {
            base.OnHoverEnd(character);

            // Do something when a character stops looking at this object.
            // e.g. Disable outline effect
        }
    }
}

Example (Implement the IInteractable interface)

namespace SurvivalTemplatePro
{
    public class InteractableTest : MonoBehaviour, IInteractable
    {
        public bool InteractionEnabled { get; set; }
        public string InteractionText => "Interaction Text";
        public string DescriptionText => "Description Text";

        public float HoldDuration => 0f;

        public event UnityAction onInteracted;
        public event UnityAction onDescriptionTextChanged;
        public event UnityAction<bool> onInteractionEnabledChanged;


        public void OnInteract(ICharacter character)
        {
            // Do something when a character interacts with this.
            // e.g. press a button
        }

        public void OnHoverStart(ICharacter character)
        {
            // Do something when a character starts looking at this object.
            // e.g. Enable outline effect
        }

        public void OnHoverEnd(ICharacter character)
        {
            // Do something when a character stops looking at this object.
            // e.g. Disable outline effect
        }
    }
}

Last updated