Forum rules - please read before posting.

Inventory - Mouse versus Control Pad Cursor

edited October 2021 in Technical Q&A

Hey,

I've been making some really good progress getting control pad stuff working in my game. I've reached a place where I like the overall approach which is a mix of detecting when the player uses a certain Rewired input device, and then changing AC's input method for the most appropiate option.

I'm having trouble with my inventory menu however.

If the player is using keyboard and mouse, this is how it performs:
AC input method: Mouse and keyboard
Cursor: software

Notice how the inventory elements change colour when the cursor passes over and the name labels appear. The name label stuff is a slightly custom affair done a while back.

If the player is using a control pad:
AC input method: keyboard or controller
Cursor: software

If the player is using a control pad, the input method changes to "keyboard or controller" so a simulated cursor can be used. The inventory elements / cursor don't react in the same way, and I'm not sure how to resolve that.

Comments

  • Is the input method changed to Keyboard Or Controller before or after the menu is turned on?

    What is the Menu's "Source", and if Unity UI, are you using a custom Event System?

  • edited October 2021

    Hey Chris, so I've done a bit more debugging with this. Turns out when using the control pad you can examine items so the cursor is interacting with them. It's just a case that my custom name labels aren't appearing when using the simulated cursor.

    I'm not using a custom Event System.

    The way I set this up a couple of years back is I have a script which turns on a menu using .hoverItem:

    void Update()
        {
            if (AC.KickStarter.stateHandler.IsPaused())
                return;
    
            if (KickStarter.runtimeInventory.hoverItem != null)
            {
                (AC.PlayerMenus.GetElementWithName("InventoryName", "NameLabel") as AC.MenuLabel).label = KickStarter.runtimeInventory.hoverItem.label;
                if (!inventoryName.IsVisible())
                {
                    inventoryName.TurnOn(true);
                }
            }
    
            else
            {
                inventoryName.TurnOff(true);
            }
        }
    

    The menu is a Unity UI set to follow cursor:

    I've narrowed it down to the line if (KickStarter.runtimeInventory.hoverItem != null)

    If I put a breakpoint on that check when using mouse and keyboard, when the cursor passes over an inventory item it hits the if check and the label menu appears.

    If I'm using the control pad (simulated cursor) it doesn't hit the breakpoint when the cursor is over an item. It only kicks in when the cursor is over an item AND I press a button linked to the InteractionA input.

  • edited October 2021

    A bit more info; it seems to be that the Unity UI button highlights for the inventory slots aren't kicking in with the control pad cursor. I assume that makes sense why .hoverItemisn't doing anything

    I cranked up the button highlight colour to make it more noticable. With keyboard and mouse the highlight of the slot kicks in fine. With control pad, the highlight doesn't happen until InteractionA is pressed.

  • I may have recreated this, thanks for the report. I'll look into it further and let you know if I need any more details.

  • Remedying this should just be a case of checking Auto-select valid UI raycasts? in the Menu Manager.

  • edited October 2021

    I'm not seeing an option for Auto-select valid UI raycasts? in my Menu Manager. Where should this option be located?

  • It appears at the top when using Keyboard Or Controller input.

  • edited October 2021

    Thanks. Yep. Got it. Confirmed it works! :)

    I'm curious though, why would the controller cursor have worked fine with highlighting pause menu and conversation options, but not inventory slots?

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.