Forum rules - please read before posting.

Changing the way Items are Deselected

For my current project I'm trying not to use the inventory menu but instead have all the items exist as GameObjects within the scene. Using a hotspot and the ActionList actions Object:Visibility and Inventory:Select I've made it so that when you click on one of the objects in the scene it disappears from the scene its selected as an item (basically simulating the player picking the item up).

The problem I've been struggling with is simulating putting the item back. I've messed with the inventory interactions of the hotspot so that interacting with it while holding the item makes the original object visible again, but that doesn't work if the item is deselected in a different way.

So, my question is: is there a way to make it so that a selected item is only deselected if used on the right hotspot? OR is there a way to trigger an ActionList to make the original object visible again automatically as soon as the item is deselected?

Comments

  • is there a way to make it so that a selected item is only deselected if used on the right hotspot?

    Depending on your settings, and AC version, yes. Check your Settings Manager's "Inventory settings" panel for the presence of the option Unhandled interactions deselect active item?.

    is there a way to trigger an ActionList to make the original object visible again automatically as soon as the item is deselected?

    Yes - it's possible to have a custom script hook into the OnInventoryDeselect custom event to run an ActionList (or some other code) when a specific inventory item is de-selected. For example:

    using AC;
    using UnityEngine;
    
    public class RunActionListOnItemDeselect : MonoBehaviour
    {
    
        public int reactToItemID;
        public ActionListAsset actionListAsset;
    
        private void OnEnable () { EventManager.OnInventoryDeselect += OnInventoryDeselect; }
        private void OnDisable () { EventManager.OnInventoryDeselect -= OnInventoryDeselect; }
    
        private void OnInventoryDeselect (InvItem invItem)
        {
            if (invItem.id == reactToItemID)
            {
                actionListAsset.Interact ();
            }
        }
    
    }
    
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.