Forum rules - please read before posting.

Use inventory like The Long Reach

Hi Every one,

I woulkd like to make an inventory systeme like the game "The Long Reach".
During gameplay i press the inventory button and it appears and i have some informations on the object.

But now i want to do like in the video below :
https://drive.google.com/file/d/1Eic6mMqot5wqnI3-eCjUWFd2QRPyMzzo/view?usp=sharing

When the player arrives on a hotspot, he can either interact or by pressing the inventory key use an object, And that's where I need help, I don't see how to set this up.

Thanks for the help

Comments

  • When the player arrives on a hotspot, he can either interact or by pressing the inventory key use an object,

    Can you expand on this? Presumably, pressing the inventory key then brings up an additional menu from which to select an item. What inputs are you using for each?

    If that's your intent, you'll want to set your "Interaction method" to "Choose Hotspot Then Interaction". This allows for the way in which a Hotspot is used to be chosen after the Hotspot is selected, by choosing the interaction type from a menu.

    This menu can include inventory items - see the 2D Demo, which uses the same setting.

    This Interaction menu doesn't need to have Interaction elements - it can contain just an InventoryBox element for you to then select an item from.

    The challenge here is to open this when pressing a new input (e.g. "SelectItem"), while having "InteractionA" run the Hotspot's Use interaction.

    This can be done with custom scripting, by overriding AC's InputGetButtonDown function. Something like this should do it:

    using UnityEngine;
    using AC;
    
    public class InputOverrideTest : MonoBehaviour
    {
    
        void Start ()
        {
            KickStarter.playerInput.InputGetButtonDownDelegate = CustomGetButtonDown;
        }
    
        private bool CustomGetButtonDown (string buttonName)
        {
            if (buttonName == "InteractionA")
            {
                Hotspot activeHotspot = KickStarter.playerInteraction.GetActiveHotspot ();
                if (activeHotspot)
                {
                    return Input.GetButtonDown ("SelectItem");
                }
    
                return Input.GetButtonDown (buttonName);
            }
    
            try
            {
                return Input.GetButtonDown (buttonName);
            }
            catch {}
    
            return false;
        }
    
        private void Update ()
        {
            if (Input.GetButtonDown ("InteractionA"))
            {
                Hotspot activeHotspot = KickStarter.playerInteraction.GetActiveHotspot ();
                if (activeHotspot)
                {
                    activeHotspot.RunUseInteraction ();
                }
            }
        }
    
    }
    

    You'll need to make sure both InteractionA and SelectItem are defined in your Input Manager, and that Mouse clicks have default functionality? is unchecked in your Settings Manager.

    Further tweaking may be required (e.g. direct control of the Interaction menu), but let's focus on getting the menu to appear at the correct time first.

  • edited December 2021

    Sorry, I didn't specify that i use a direct movement method with keyboard or Controller so i don't have Mouse clicks have default functionality in my Settings Manager.
    For now my InteractionA is "U" and InteractionB is "Y" and the SelectItem is set on "I".

  • i use a direct movement method with keyboard or Controller so i don't have Mouse clicks have default functionality in my Settings Manager.

    You'd only need to uncheck that option if it's visible.

  • Maybe i find a solution without personnal script, I finalize some tests and I confirm this

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.