Hi everyone! Running into an issue with my inventory system, hopefully there's an easy fix I just haven't been able to find yet.
I have an inventory similar to Quest for Glory, with an inventory menu button to pause the game and display the inventory menu, and an exit button in the inventory menu. (image of inventory menu -- forgive the horribly temp art
https://i.imgur.com/lcrA6Jn.jpg)
This works well enough, with players being able to select an inventory item, click the exit button to return to gameplay, then use the item on things in the environment. I have an ActionList set up to hide both the Inventory and InventoryExit buttons when you exit the inventory menu, and that same action will make the Inventory menu button reappear in the top-right.
I borrowed this behavior from another Technical Q&A thread, which was super helpful (image:
https://i.imgur.com/VlzlzR6.jpg). Here is my ActionList for the InventoryExit button as well: (
https://i.imgur.com/HtbWe8C.jpg)
My issue is that if I combine two items in my inventory, the inventory menu will automatically close, but the exit button will remain on screen. I've captured a video of this behavior here:
https://www.dropbox.com/s/4th8k89ihjv49c2/InventoryCombine_issue.mp4?dl=0Since the player isn't clicking a button to close the inventory, this makes sense of course. So I tried to work around this issue by adding an "ActionList when turn off" onto the Inventory menu that simply turns off the exit button if the Inventory isn't visible. Unfortunately, it appears that if you combine two items in the inventory, any ActionList that should fire when the Inventory menu turns off isn't followed.
I ran a quick experiment by creating an "ActionList when turn off" for the Inventory that exits the game whenever the inventory menu closes. Opening and closing the inventory normally would kill the game, but combining two items in the inventory would close the inventory without killing the game, suggesting that specific behavior skips any ActionList the user may have set up.
If anyone needs any more specifics here, please let me know! Thanks!
Comments
I'm on Unity 2017.3.1f1 (Personal), and am running AC version 1.62.2.
Here is a screenshot of the properties of the combine action from the video: https://i.imgur.com/uUpiOoS.jpg
Here is a screenshot of the properties for the Inventory menu itself: https://i.imgur.com/bAB8IvZ.jpg
Here is a screenshot of the properties for the Exit button that displays above the Inventory menu when it is active: https://i.imgur.com/wMfE10q.jpg
And here is a screenshot of the properties for the "open Inventory" button that displays at the top-right during gameplay: https://i.imgur.com/MA05a8d.jpg
If you'd like to see anything else, just let me know!
To answer your initial question, the only logic I have set for the InventoryExit button is that "InventoryExit_ExitButton_OnClick" ActionList: https://imgur.com/HtbWe8C
I've tried setting up an "ActionList when turn off" for the Inventory menu as well that is a simple one-step ActionList to turn off the InventoryExit button any time the main Inventory closes: https://i.imgur.com/5wQjFxQ.jpg
I've tested this logic by changing it to exit the game any time the Inventory closes, and it worked in every instance of opening and then closing the Inventory, except in the instance of combining two Inventory items. In that case, the menu closes without following the "ActionList when turn off" rules.
I'll try altering the Appear Types to During Gameplay and seeing what that does. Thanks!
I implemented the menu systems using Lock/Unlock instead of Turn On/Turn Off as you recommended. This has successfully fixed the issue of the InventoryExit button remaining visible when two objects in the inventory are combined. Now, when I combine items, both the Inventory menu and InventoryExit button remain on-screen until they are locked again by clicking on the Inventory Exit button.
While this is a fix for the initial problem, it introduces a new one: having the inventory active During Gameplay means I need to use the Engine: Manage systems action to constrain player activity, but this doesn't "pause" the game, it just prevents new actions from taking place behind the menu. If a character is in the middle of movement and the Inventory is brought up, the character will continue moving in the background until they've reached their destination. This can cause issues with characters walking into/out of triggers in the background.
I'm thinking a simple(?) solution to my problem might be to have an option to keep the Inventory menu from automatically closing on an item combine? It doesn't solve the underlying problem where the inventory menu closing after an item combination ignores any associated Turn Off actions attached to the Inventory menu, but it does prevent it from becoming an issue.
So, interesting development: I created a duplicate project and updated Adventure Creator to the latest version (1.63.2). I reverted the menus to their former behavior, so clicking the Inventory button in the top-right hides the Inventory button and Turns On the Inventory menu and InventoryExit button, and clicking the InventoryExit button Turns Off the Inventory menu and InventoryExit button, then shows the Inventory button in the top-right again.
I combined two items in the inventory and both the Inventory menu and InventoryExit buttons properly closed, and the Inventory button re-appeared at the top-right. So far so good! Unfortunately, clicking the Inventory button to re-open the Inventory menu does nothing. So, the Inventory button is un-hiding properly, but its attached ActionList doesn't seem to be working anymore. I've attached a video demonstrating this behavior (along with a look at the InventoryButton ActionList for reference) here: https://www.dropbox.com/s/h9wx70tcpvd1how/Item_Combine_6-17.mp4?dl=0
I added your bit of code to the TurnOff method at the line you asked for and recorded the following video: https://www.dropbox.com/s/t0garc77v3spnep/InventoryButton_Test_6-18.mp4?dl=0
It seems that in normal circumstances it throws the text into the console, but on item combines it does not.
You should then get a warning message upon combining the two items. This time, select the message in the Console window to reveal the full message - and paste the contents as a reply.
Forcing off InventoryExit now!