Forum rules - please read before posting.

Is it possible to make it so that dropping an item onto the player triggers its Examine interaction?

Hi! Sorry if this is a silly question, I'm very new to AC and game development in general! I was wondering, since there's an option to trigger the "Examine" of an item by dragging and dropping it onto itself, can something similar be done but with dropping it onto a specific hotspot (I was thinking the player's), instead? As in, every time an item is dragged onto the player, no matter which item it is, its Examine interaction is activated?

Technically, there's the workaround of not using the Examine interactions at all and just assigning each inventory item an interaction through the player's hotspot component, but if I do that, it seems I'll have to copy-paste this set of interactions into each scene I make... Not ideal for the long-term; and I haven't really been able to come up with anything better than that. But, of course, my knowledge is really limited haha.

Comments

  • Welcome to the community, @Plushie.

    You can do this with a short script attached to the Player's Hotspot:

    using UnityEngine;
    using AC;
    
    public class ExamineItemHotspot : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotInteract += OnHotspotInteract; }
        private void OnDisable () {EventManager.OnHotspotInteract -= OnHotspotInteract; }
    
        private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
        {
            if (hotspot == GetComponent <Hotspot>() && button == hotspot.unhandledInvButton)
            {
                KickStarter.runtimeInventory.LastSelectedInstance.Examine ();
            }
        }
    
    }
    

    Paste that in a C# script named ExamineItemHotspot, and place on your Player's Hotspot. The Hotspot will need to have an "Unhandled inventory interaction" defined, but left empty - this script will react when it's run and do the rest.

    it seems I'll have to copy-paste this set of interactions into each scene I make

    Even without the script, this wouldn't be necessary. The Player character can be made a prefab that is spawned into each scene automatically. If you set the Player Hotspot's Interaction Source to Asset File, you could then assign each of the original item Examine ActionList assets into the Hotspot Inspector, avoiding the need to create duplicates.

  • @ChrisIceBox Hi, thank you so much for your reply! :} Works perfectly. I'll keep the rest of your advice in mind, as well.

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.