Blocking Background Interactions while Inventory is Open

  • #1, by nate-ingraciaMonday, 30. September 2024, 02:42 4 months ago
    So I'm having a problem with my game's Inventory system. When you open the Inventory, it brings up a box in the middle of the screen, with a bit of margin on the outside. The interface area is limited to the interior of the box, so that I can have an interaction that closes the Inventory when the cursor leaves the area. If you open the Inventory while your cursor is outside the box, the Inventory persists until you move the cursor inside, at which point it can be removed from the box, closing the Inventory.

    The problem I am experiencing is that when you open the Inventory while the cursor is outside the box, you can still click items in the main room and the character can still walk around, but there's a giant box in the way. I'm looking for a way to disallow all background interactions while the Inventory is open.

    Newbie

    15 Posts


  • #2, by jessica-collinsMonday, 30. September 2024, 08:22 4 months ago
    papa's games louie: create a semi-transparent overlay covering the entire screen when the Inventory opens. This overlay should capture all mouse events, preventing clicks from reaching the underlying game elements. Ensure that when the Inventory is opened, you disable input handling for the main game. This can be done by setting a flag (e.g., isInventoryOpen) and checking it in your input handling functions. If the flag is true, ignore all input events related to movement and interactions. If applicable, you can lock the cursor to the Inventory box when it opens. This way, the player cannot interact with the background until they close the Inventory. Implement an input blocker that listens for any mouse or keyboard events when the Inventory is open. If such an event occurs, simply ignore it.

    Newbie

    1 Posts

  • #3, by esmeraldaMonday, 30. September 2024, 09:16 4 months ago
    while this was obviously a spam-bot answering you, one thing was a viable solution:

    create a second interface with a transparent background as big as your game resolution.

    show this second interface at the same time you show your inventory. This will block the interaction but you will still be able to trigger the "cursor leaves interface area" action of the inventory.

    When closing the inventory, hide the second interface as well.

    Make sure the second interface is in the list of interfaces BELOW the inventory.
    This list defines the order of the interfaces in the game when they are shown at the same time. When the interface used to block the input is in the list below the inventory, it will be below the inventory in the game, so you can access the inventory.


    The forum is a bit deserted by now (bots galore, but not many users). It's much more lively in the Visionaire Discord server. So if you want quicker help and more people answering, consider dropping by there. The link is at the bottom of the page.

    Key Killer

    535 Posts

  • #4, by nate-ingraciaMonday, 30. September 2024, 16:22 4 months ago
    Ah, thanks for the help! It actually was not obvious to me that was a bot, I didn't expect bots to have somewhat coherent answers lol

    Definitely joining that discord

    Newbie

    15 Posts

  • #5, by sarahharalsonTuesday, 22. October 2024, 09:07 3 months ago
    It sounds like you're experiencing frustrating UI issues with your game's inventory system. If the inventory box obstructs interactions in the main game when opened, you might want to implement logic to disable background interactions, similar to how the io games restricts movement when the game starts. This ensures players can focus on their inventory management without distractions.

    Newbie

    1 Posts

  • #6, by slopeMonday, 11. November 2024, 10:20 2 months ago
    I would need to discuss this matter with you. a behavior that I do not typically engage in! An article that will make readers feel is something that I appreciate reading. A further thank you for allowing me to leave a comment! Slope


    Newbie

    4 Posts

Write post