Forum rules - please read before posting.

Lock / unlock Mouse during gameplay.

3D FPS. I created a "diablo like" inventory which is permanently visible at the bottom of the screen. While running, the cursor is locked, with the "i" key I can release the mouse and access the inventory, for example to use an item.
I would now like the mouse to automatically lock again as soon as I have successfully used an item.

Technically, I created an invisible menu for pressing the i key and set it there via Action Script - player constrains -> cursor /mouse lock/unlock... .

My approach was that I simply "turn menu off" behind each desired interaction via action list. This also works, but in this scenario the hotspots disappear or I can no longer interact with them.

What am I missing?

Comments

  • EDIT: When i hit "i" again, i can see the hotspots again.

  • Does the Menu span the full screen, or pause gameplay? It might be that the enabled state of the Menu prevents interactions.

    You needn't rely on an invisible Menu to run Actions when a key is pressed, however. For that, you can use Active Inputs - which are a way of running ActionLists when a particular input is pressed.

    See the Manual's "Active Inputs" chapter for details.

  • Thank you for your prompt reply. I tried it with the active input and refer to an action list there (as soon as "i" was pressed for the inventory button). A bool checks in the background whether the button was pressed so that I can easily lock and unlock the mouse with "i". Only the hotspot problem remains or can now be specified a little more precisely:

    The player uses a rod to catch a fish. I unlock the mouse with "i", select the rod and click on the pond. By clicking on the pond and as the last action in the action list, I call up the same action list that I also used for the active inputs to lock the mouse again... but then unfortunately the hotspots are no longer visible or cannot be seen anymore .I can't interact with them. But if I press "i" again, my mouse is unlocked (as desired) but I can use/see the hotspots again. But as soon as I press the "i" button again, I have a locked mouse with no visible hotspots.

  • Is this a case of Hotspots being non-interactive because the mouse is no longer over them? How are Hotspots normally interacted with?

    You mention a bool-check in the background - is this to say you're checking every frame if a bool is set to True? This should not be necessary - you can use a bool that switches between True/False as part of the Active Input, and follow this up with an Action that either locks/unlocks the cursor, with no need for a "background" ActionList.

    If you lock/unlock the cursor separately, you'll have to also update the bool so that the Active Input still runs correctly.

    I think it's best to see some screenshots of your setup - it'll be easier to see exactly what you're dealing with.

  • All right. 1st of all: Here is a video which shows the problem. After fishing, i am not able to see or interact with coins or other hotspots:

    here are some screenshots:

    The "Backround Bool"

    The ActiveInput (for pressing "i" and release the mouse)

    The ActionList in the ActiveInput (checks if "i" was already pressed and set the bool)

    The Action List of the Fishing Rod (Inventory Action)

    here are also some screenshots of the Inputs and general settings of AC. Just tell me if you need more.

    Inputs:
    https://i.postimg.cc/kG5FCF4r/inputs.png

    Inventory Menu:
    https://i.postimg.cc/wvgQfdYj/inventory-menu.png

    Hotspot Settings AC:
    https://i.postimg.cc/J42K1gZp/hotspotsettings.png

    General AC Settings
    https://i.postimg.cc/d16mgSJm/settings2.png

  • Where/when/how are you checking the bool to affect the Menu?

    Don't rely on a bool, though. Your Active Input ActionList can start with a Menu: Check state to determine if the Inventory menu is locked and then unlock/lock it accordingly.

    If you want to control e.g. cursor lock when the Inventory menu is turned on/off, you can run those Actions in the menu's "ActionList when turn on/off" fields.

    Doing it this way allows you to lock the Inventory menu separately from the Active Input, and still have the Active Input work correctly.

    Once done, enable the AC Status window via the bottom of the Settings Manager. If the issue persists, what does the window display at the time the issue occurs?

    In a duplicate/backup project, import the latest AC release to see if it's still occuring.

  • oh, I thought that was evident from the screenshots. I created the bool "isLocked" which is set to "true" by default. I deleted the invisible menu that I used as a workaround before and, as you advised, replaced it with the "ActiveInput" method.

    In "ActiveInput" for the "i" key, I now check whether the "isLocked" variable is set to "true". If so, the mouse should be released over "PlayerConstrain" so that I can access the permanently visible inventory. Then the bool "isLocked" is set to "false" so that I can tie the mouse back to the center of the screen by pressing "i" again. After that, the "isLocked" is set back to True.

    Since my inventory is permanently visible below, I don't really understand how to work with "inventory is turned on/off".

  • Don't rely on a bool variable - access the locked state of the Menu directly with the Menu: Change state and Menu: Check state Actions in your Active Input's ActionList.

  • edited November 2022

    Ok, i worked with that method:

    1. Turn on / off Action List in the "Invetory Menu" with the player Constrain Actions to enable /disable the mouse lock
    2. I locked the inventory on startup (which makes it unvisible?)
    3. With the Active Input i check if the menu is locked and switch the state, depends on...
    4. At the fishing rod, i put a last AL to lock the menu again.

    At least, i have exactly the same issue. After fishing, the cursor locks in the middle but the Hotspots are not visible, until i press "i" again.

    EDIT: Ok, it was an VErsion Issue..i dublicated the Project and switcht from May to November and now it works.

    Still my Inventory is invisble, when i check "Lock Inventory"...how can i still make it visible all time?

  • When a menu is locked, it will not turn on - even when its "Appear type" condition is met.

    If you want to display it all times, set the Appear type to Manual and check Enabled on start?.

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.