Forum rules - please read before posting.

Using an item on a hotspot in direct input / hotspot player vicinity

My game is using direct input and you interact with hotspots by standing on them and pressing space. I'd like to use items on the hotspot by standing on the hotspot and then selecting the item in your inventory. However, when I add an inventory interaction to my hotspot, it requires me to click on the item in my inventory to "pick it up" from my inventory, close the inventory, and then click on the hotspot.

How can I change this to activate just by clicking on the item while standing on the correct hotspot? I also tried accomplishing this by creating a standard interaction "Use" action list for the item itself, but I don't see anything in action lists to detect which hotspot I am standing on.

Comments

  • I'd like for this to be possible with the Events Editor and the Hotspot: Run Interaction Action. Currently, however, you can't define the Inventory interaction to run if you're using a Hotspot parameter. I'll see about amending this in v1.80.1.

    In the meantime, this script - placed in the scene - should cause an item to become combined with the active Hotspot automatically when selected:

    using AC;
    using UnityEngine;
    
    public class AutoUseItems : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnInventorySelect_Alt += OnInventorySelect; }
        private void OnDisable () { EventManager.OnInventorySelect_Alt -= OnInventorySelect; }
    
        private void OnInventorySelect (InvCollection invCollection, InvInstance invInstance)
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot ();
            if (hotspot) hotspot.RunInventoryInteraction (invInstance);
        }
    
    }
    
  • I've given it a try, but since the inventory item has no "use" action list (since the action list for using it on a hotspot belongs instead to the hotspot), when I click on the item in the inventory it goes to pick up the item still so that I can drag it to said hotspot. The difference now is that after I close my inventory while holding the item, I can click anywhere on the screen instead of on the hotspot. Ideally I'd like it to trigger just by clicking the item in my inventory while standing on the correct hotspot.

  • The script shouldn't require a "Use" ActionList - it should kick in at the moment the Inventory gets selected.

    Place a Debug.Log statment inside the OnInventorySelect function, i.e.:

    Debug.Log ("Selected " + invInstance.ItemLabel);
    

    Does this appear in the Console when you select ("pick up") an item in the Inventory?

    If not, share your Settings Manager and the properties of your Inventory menu's InventoryBox element, as well as your AC/Unity version numbers.

  • edited March 20

    I can indeed see the debug log messages

    I went to log the hotspot as well, which came back null even though I am standing on the hotspot and can see the hotspot highlight pop up, looks like this line is not grabbing the hotspot atm.

    Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot ();

    Upon further investigation it seems that going into my inventory menu (pops up over most of the screen) might be messing with the hotspot detection. When my cursor is on the inventory menu UI, the hotspot highlight icon disappears, but when my cursor goes over the areas the inventory menu UI doesn't cover, the highlight comes back and shows over the menu. This may be why dragging the item out of the inventory and clicking at the edges correctly executes the hotspot

  • I need to see your full Settings Manager - how are Hotspots being detected?

    If you're using a Hotspot Detector, try replacing the line you mention with:

    Hotspot[] hotspots = KickStarter.player.hotspotDetector.GetAllDetectedHotspots ();
    Hotspot hotspot = hotspots.Length > 0 ? hotspots[0] : null;
    
  • That looks to have fixed it! I am indeed using a Hotspot Detector. Thanks!

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.