Forum rules - please read before posting.

Callback for used item on a character

Hello I need a callback from script when we use item on a player character. Is it possible?

Comments

  • The OnHotspotInteract event will be called when using an Inventory item on a Player's Hotspot. You can compare the Hotspot with that of the Player, and the type of interaction with GetButtonInteractionType:

    using UnityEngine;
    using AC;
    
    public class PlayerItemEvent : MonoBehaviour
    {
    
        public Hotspot playerHotspot;
    
        void OnEnable() => EventManager.OnHotspotInteract += OnHotspotInteract;
        void OnDisable() => EventManager.OnHotspotInteract -= OnHotspotInteract;
    
        void OnHotspotInteract(Hotspot hotspot, AC.Button button)
        {
            var buttonType = hotspot.GetButtonInteractionType(button);
            if (hotspot == playerHotspot && (buttonType == HotspotInteractionType.Inventory || buttonType == HotspotInteractionType.UnhandledInventory))
            {
                Debug.Log("Item was used on Player");
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.