Forum rules - please read before posting.

Direct navigation Inventory Menu

edited September 2024 in Technical Q&A

Unity 2022.3.44f1
AC 1.81.6

Hello everyone, I am looking for help. I'm doing my game full playable by keyboard, without using the cursor, only activating it if the pause menu is activated. I managed to make the hotspots work by proximity and that the interactions menu can cycle using the input axis "CycleInteractions", assign the inputs "InteractionA" and "InteractionB". Everything was working, with a little work at first but it worked, however, with the inventory I still can't make it work the way I want.
I would like that when the inventory is activated I can navigate through it only using the "Horizontal" axis and when using "InteractionA" the interactions menu of the selected item is displayed. To use an item on a hotspot, the interaction would have to be by giving "use" to the item within the trigger of the hotspot with which you want to use it.
Making the inventory menu moveable with direct input was hell, but I managed to get it working by enabling the "Pauses game?" option. in the inventory menu settings. Currently I can move between objects, but "InteractionA" doesn't seem to work to show me the interactions menu.

The interactions I want to replicate are used in games from Harvester Games, such as The Cat Lady, Downfall and Lorelai.

I left the video with the exact minute (PD: min 1:47 embebed video modifies the &t yt argument). There the player uses the book, there he finds a screwdriver, then he uses it to open the mailbox.

Here there's a video of my game, showing the issue
https://drive.google.com/file/d/1_REu1tVezAkQslwlAtprWWdTz4WKqwP2/view?usp=sharing
Pressing "InteractionA" is doing nothing.

Interface and Inventory settings:
https://imgur.com/a/nIlfPQv
Global menu settings:
https://imgur.com/a/axRpSq1
Inventory menu settings:
https://imgur.com/a/nwRnfSc

Comments

  • Welcome to the community @DreadZitoDev.

    Making the inventory menu moveable with direct input was hell, but I managed to get it working by enabling the "Pauses game?" option. in the inventory menu settings. Currently I can move between objects, but "InteractionA" doesn't seem to work to show me the interactions menu.

    To be clear: by default, Direct-navigation of menus requires the game to be paused (see the Directly-navigate Menus when paused? option at the top of the Menu Manager). Direct-navigation of Menus during gameplay is possible, but requires the use of the Engine: Manage systems Action to allow for it.

    For interacting with items - when dealing with Unity UI-based Menus, it's actually the "Submit" input button that deals with interactivity. You can adjust this by creating a custom Event System, but duplicating your InteractionA input and renaming it to Submit should do the trick.

    To have an Item be automatically used on the game's active Hotspot when selected, you'll need a custom script:

    using AC;
    using UnityEngine;
    
    public class AutoUseInventory : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnInventorySelect += OnInventorySelect; }
        private void OnDisable () { EventManager.OnInventorySelect -= OnInventorySelect; }
    
        private void OnInventorySelect (InvItem invItem)
        {
            if (KickStarter.playerInteraction.GetActiveHotspot ())
            {
                KickStarter.playerInteraction.GetActiveHotspot ().RunInventoryInteraction (invItem);
            }
            KickStarter.runtimeInventory.SetNull ();
        }
    
    }
    

    To use it, copy/paste into a C# script named AutoUseInventory.cs, add to the scene, and then use the Inventory: Select Action - or Select item if Interaction is unhandled? option - to have the item be selected when "Using" it.

  • edited September 2024

    Thank you Chris, now I can navigate to the inventory during gameplay.
    But I can't see the interactions menu though.
    I crated the custom EventSystem, and asigned it to the menu settings field. I found out something interesting, it seems like AC is ignoring onClick calls from the buttons. "Submit" input is being pressed, buttons are behaving like they're pressed but nothing happens. However it does work with "InteractionA" on Interactions menu because that menu somwhow listens to InteractionA press before Sumbit.

    I tryed two things, the first one is to modify "Submit" in the Input Manager from project settings to be the same key as "InteractionA", and the last try was just repleacing the SubmitButton field from EventSystem's Standalone Input Module to "InteractionA", both tries does the same thing; items aren't showing their interactions and hotspots became imposible to interact with them. I'll record a video to show it
    https://drive.google.com/file/d/1Yzy_SDT57G3aEWh_OP1jepDec1hMz7Kf/view?usp=sharing
    The interaction menu that is displayed is from the coffee maker machine, items can't show them.

    I did other tests by myself and also find out that navigating through inventory isn't firing any event of "EventManager.OnInventorySelect". So I modified my Hotspot detection script to try to solve it from code. I modified this and now items are selecting
    https://imgur.com/a/egWtwRM
    (send image of my code because formatting isn't working for me hah)
    And When pressing "InteractionA" apparently nothing happens, but interaction menues are being set, but they get turned off for some reason.
    https://drive.google.com/file/d/1zTW-qd7PDaLKhHEccOR0n3a29EdKyq7M/view?usp=sharing

  • I tryed two things, the first one is to modify "Submit" in the Input Manager from project settings to be the same key as "InteractionA", and the last try was just repleacing the SubmitButton field from EventSystem's Standalone Input Module to "InteractionA"

    Best to rely on the first method. AC has its own Event System component - Optional Mouse Input Module - that assists with direct navigation. You could incorporate this into your custom prefab, but it's easier to rely on the Input Manager instead.

    I'm not 100% sure of how things are behaving in the videos - the two items keep switching, and I don't know what inputs are involved or what custom scripts are in use.

    If you can PM me a .zip of your project, with instructions on how to recreate the issue, and how you'd like it to be instead, I can take a look.

  • edited September 2024

    UPDATE: I modified my custom script "HotspotNearest" that shows interaction menues with "InteractionA" key, that script was causing the interaction menues to hide in the inventory cause it was not checking if interaction menu was opened by inventory. Now it opens interactions in the center of screen, but interaction menu isn't triggering any interaction by pressing Submit or InteractionA.
    HotspotNearest script is attached to HotspotDetector inside the player prefab

    I prepared the zip file here:
    [REMOVED BY ADMIN]

    The scene I'm working on is in "Assets/_DownfallProject/Scenes/Levels/House/Example 1 - Kitchen"

    The way I'd like to the inventory work is this:

    • Press tab to open the inventory
    • Navigate the inventory with the keyboard to select the desired item
    • Press E key (InteractionA or Submit) for displaying the item interactions (menu should be displayed neear the item)
    • Navigate through interactions with keys (this is currently working for Hotspots)
    • Press E key again to trigger the selected interaction
    • If that interaction is "Use" check if the player is colliding with a hotspot and trigger the item action of that hotspot

    I don't want any cursor interaction, only if we're in the pause or settings menu.

  • edited September 2024

    I have removed your link. AC is a commercial asset, please never share a public link to download it.

    I will take a look, nonetheless.

  • edited September 2024

    Ok sorry, I didn't consider it. Where could I have sent that? Does this page have dms?

  • Click a username to bring up their profile page, then "Message".

    The custom script may not be necessary, but the main issue is to do with the Event System forcing the selection of Interaction icons. Normally this is intended, but with "Cycling Menus And Clicking Hotspot" mode, the selection is simulated.

    Try the following:

    • Disable the HotspotNearest custom script
    • Set Select interactions by to Clicking Menu
    • Set See interactions with to Click On Hotspot
    • Set Close itneractions with to Click Off Menu
  • Thank you Chris! It worked as expected!!
    Now I just need to disable the mouse click for triggering hotspots, Event System wasn't selecting interactions by default, even with "Auto select first element" in settings, but I asume that check if for the simulated selection that you mentioned, not the EventSystem one.

    So I fixed it attaching this script in the InteractionMenu prefab

    `public class InteractionMenuSelect : MonoBehaviour
    {
    private void OnEnable()
    {
    var menu = PlayerMenus.GetMenuWithName("Interaction");
    var firstVisibleElement = menu.GetFirstVisibleElement()?.GetObjectToSelect();
    if (firstVisibleElement)
    EventSystem.current.SetSelectedGameObject(firstVisibleElement);
    }

        private void OnDisable()
        {
            EventSystem.current.SetSelectedGameObject(null);
        }
    }
    

    `

  • To prevent mouse clicks triggering Hotspots, uncheck Mouse clicks have default functionality? in the Settings Manager.

    If you need to force the selection of a Menu when it turns on, you can use the Menu: Select Action in its ActionList when turn on asset.

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.