Forum rules - please read before posting.

Selecting an inventory item to close the menu

edited November 2014 in Technical Q&A
Hello,

I'm having a problem which hopefully isn't too hard. Currently, I'm making a first person game, but it's still a point and click. This creates several problems with the inventory handling due to the mouse moving the camera. Basically, at the moment, I call the menu by pressing the button m, and I put the same key in the "ToggleCursor" input.
This way, when you open the inventory, you can also effectively use the cursor to select an item in the inventory.
Of course, this creates the problem that you can move, but can't use the cursor to move the camera anymore, otherwise it would be a giant mess (like, you go down with the mouse and move the camera at the same time...). I'm fine with this though as I don't see any solution.

So, here's my question: currently, to get back to the normal situation, you have to close the inventory by pressing M again to be able to fully move around with the mouse FPS camera too. 
If you select an inventory item, though, the menu won't close automatically.
Yes, you can use an item without closing the inventory and close it later if you are already facing your hotspot but it's still a little annoying.
So, is there a way to close the inventory and restore the cursor to normal at the same time exactly when you have selected an inventory item, without having to press m again?
 I hope it doesn't involve scripting... :(
 
Please note that I don't want the game to pause when you open the inventory, otherwise it would've been obviously super easy.

edit: uh-oh. Sorry to add another question... I Just noticed that if I press "esc" to turn on the pause menu, even if the game is paused I can still press m to open\close the inventory, which is not good, as you could mess up the cursor this way. Any way to prevent this from happening, too? =( Yes, I know that I can do "Turn off Menu" from an ActionList but the problems remains, both because because if I do that, the inventory closes, but the cursor doesn't go back to normal. And, because I can still press m whenever I want during the pause menu.

Comments

  • When the Inventory menu turns on, you can use the Player: Constrain Action to lock movement in all four directions.  I'll look into adding a similar ability to disable free-aiming as well, so that you don't need to rely on the ToggleCursor input.

    There's been a few calls for some kind of "Inventory: Check selected" Action, so I'll see about that as well.  You'd have to run that continuously while the Inventory menu is open, and close it if it returns anything other than "nothing".

    As for the Inventory menu appearing when Pause is enabled, simply lock the Inventory menu during this time.  When a menu is locked, it'll never appear until it's unlocked again.
  • edited November 2014
    No, sorry Chris my bad for the bad explaining, I don't have to necessarily constrain the player when he open the inventory (at least, at the moment I found no to reason to) - thanks for reminding me of that Action though. I just noticed that, with my system, you can move but of course you can't move the camera anymore. It gets a little weird so I might go and lock the whole movement, yeah.

    edit: oh gosh. I feel like a noob but I'm not sure how to de-constrain movement. Since there is no "ActionList when turned off" clearly I thought about creating an action list that runs on the InGame menu but it doesn't seem to be the correct approach...
     I did a Menu Check State (Inventory) -> If Menu is Visible -> if condition is NOT met -> Enable up\down\left\right movement. But maybe "Menu is Visible" isn't what I thought it was... There must be an easier way so that this runs only every time you close the menu.

    About the second part:
    If you can somewhat include an option to make that the cursor automatically stop the free aiming when you open "a menu" (in my case, the inventory) it'd be perfect. I haven't been able to find a smarter solution than putting the inventory and the toggle cursor on the same button at the moment.

    Going by your second paragraph (I'm not sure if I understand it correctly) I'd guess there is no way to currently select an item and have the inventory close automatically then, right? I'd need something that "checks" if something is selected.

    As for your last answer, unfortunately that doesn't work :(. If I do that, if you open the inventory, press ESC, then press ESC again to get back to the game, you will be able to open the inventory again, but the cursor will remain messed up until you repeat the same sequence. (This happens because the cursor is "toggled" the first time you press the inventory and then never resetted anymore)

    I guess I could force the player to not be able to open the ESC menu when he has the inventory open, but it would lead to confused players I fear..

    I'm terribly sorry for the complicated situation, it's certainly shouldn't beyour job to aid users to this point unless it's real bugs, I guess. All I can do in exchange is some free advertising of your great asset with friends :)
  • AC v1.40 will include an ActionList when turned off option for all Menus.  The Player: Constrain Action has also been updated to allow the locking of free-aiming in First Person games.  It will also include an Inventory: Check selected Action, which also lets you check if nothing is selected (and hence, NOT nothing).

    It also includes quite a few bugfixes related to menus.  If you can wait until it's released early next week, let's resume this once it's out.  If the issues aren't all resolved by then, it'll at least be easier to deal with them.
  • Well damn that's wonderful. Thanks for your hard work. Sounds like a massive update overall, I can definitely wait, I wouldn't even dare to not.
  • edited November 2014
    Solved everything with 1.40. Posting for reference:

    The problem about the "cursor switch" has been perfectly resolved but the new Free Aiming Constrain. Whenever you press the inventory button, it automatically enables the "standard aiming" cursor". When you close it, it gets back to the center in FPS mode. Infact, I even took off the cursor switch key completely =)

    The problem about opening the inventory while in the pause menu has also been resolved. This time thanks to the "ActionList when turn off" action, I simply lock and unlock it. 
    This also meant that it was no longer possible to "mess up with the cursor" as it's not mapped to the same inventory button anymore, and it doesn't change anything if you had it already opened or not when you call the Pause menu. 

    The last one was solved with the new Check Selected, but it ended up being a little more complicated than I thought due to me not considering the fact that you could've selected an item from the inventory (which now then turns off), and tried to reopen it before you used the item. This resulted in the inventory opening and immediately closing because it sees that an item is still selected. I solved this by placing a Deselect Active at the top, every time the inventory is opened.
  • edited November 2014
    Sorry for the double post but I had to address one thing.

    During gameplay, I had noticed that every single time I opened the inventory, a gameobject with the name of my "inv. opening" actionlist (the one with constrain free aim, check if selected, etc) that contained a Runtime Action List script with the actions was created in the hierarchy, and it never disappeared. This probably happened because the game kept checking if I had selected something or not, no matter if the inventory was closed

    I tried to fix this with Menu is Visible and, thankfully it worked.To not make things too long here's how it works in case someone ever needs it: (woops, I forgot to include the first action which is Inventory -> Select -> Deselect Active)
    image

    you can also restrain movement if you want, of course.
  • edited November 2014
    Okay so... this stopped working. I'm not sure what in the world the reason could be but it's the Turn Off Menu that doesn't work anymore. 
    This was before 1.40a but I checked the changelogs again and the only things that have remotely to do with this are:

    • Fixed: Lag when running Check-based Actions
    • Fixed: Variable: Check Action breaking if it's referenced Variable is deleted and the UI is not viewed afterwards
    none of them seem to have to do anything with this?

    I just ran a simple test: I created another action "Menu" "Change state" "Turn off Menu". Then set it to run as soon as you open the menu, so it should close the menu in the instant you open it. 
    It's not working. I even tried to take out any action on "AL when turn off". Either it can't find my menu anymore - but the name's not changed - or the Change State -> Turn off menu action become broken?
    If I'm doing something wrong in the testing, I don't get it :(

    Not sure if it's me but I am 100% sure it was working before?
  • edited November 2014
    Running a few other tests... it seems that the Turn Off function does work, it's just that if you merely create an actionlist on When Turn On where you tell the menu to turn off, it doesn't work because it... doesn't make it in time. So, it's not a test to be done.
    Like, the second you open the menu it should close and it doesn't manage to do that visually (at least, my menu remained open) but it still runs the actions.
    I verified this because I had a turn-off action which re-enabled the Free Aiming and basically, whenever I opened the menu, the Free-aiming basically never had even disabled itself (because the instruction was to turn off the menu immediately and it run the other action - so it re-enabled free aiming instantly).

    So, back to point A, I'm starting to suspect that the culprit could be "Menu is Visible" which isn't working properly, or the Check Selected -> Check for none Selected. Will update in case, sorry but it's not possible to edit posts after one hour...

    edit: Clicking the "run now" button  with the menu being already opened, seems to make it work. This doesn't make any sense.
  • You'll need to back up a bit.  When are you calling the ActionList in question?  If it's in the "ActionList when turn on" field, it could be because the list runs before the menu is fully on.  A couple of things to try:
    • Don't have a transition (e.g. fade) when turning the menu on.
    • Insert a (very) brief pause just after the Player: Constrain Action, to give the menu time to become fully visible
  • edited November 2014
    Yes, apologies, it's in the "when turn on" field. 
    And yeah, you were spot-on, I hadn't thought of this even if the previous test gave me a hint. 
    Tested by merely removing the transition, and it already worked! I don't care about it, so as long as it works, I'll leave it like this. Otherwise I'll also add a small pause. Sorry for the mess :D

    It's strange that it didn't happen before.
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.