Forum rules - please read before posting.

Game pause destroys inventory button and document.

edited October 2019 in Technical Q&A

Hi Chris:) The title is quite self-explanatory but I will explain in details.

I have quite simple inventory that I did long time ago following your tutorials. It's based on Unity UI same as all other menus in my game. There are not any issues with it. I can do all manipulations with inventory menu: add items, remove, combine them etc.

I have simple pause menu which I did also follow your tutorials and it's also working good, there are no any issues (at least I haven't found any problems until I got this one with documents).

Recently I started work with Inventory documents and I use them as game notes to read some information. I have document menu with titles, main text field, arrows to switch pages and exit button (standard set). So, there are also now any questions on how to use documents, it's clear and everything works good in game. To call document I use Hotshot withActionList where I have Document Open action. So I can open document, read it, switch pages and close and everything work good as I already said.

But the problems starts when I open document and press escape to call pause menu. When I do this my document disappear along with inventory button. When I press escape button again to back to game, my character still can walk, but I can't open document and inventory anymore.

I thought that it could be some issue with pause menu, but in fact pause menu does not conflict with other things like inventory or dialogues or player speech or cutscenes, music or anything else except for document.

Please hep master!

Unity 2018.1.0f2
Adventure Creator 1.66.1

https://prnt.sc/plza1f
https://prnt.sc/plzag1
https://prnt.sc/plzaih
https://prnt.sc/plzala

Comments

  • edited October 2019

    Here is a video where you can visually see what's happening. The main problem is closer to the end of the video. I am pressing escape many times just to show you that everything works fine except for document.

    https://youtu.be/H_kxLrr_dXQ

  • Recreated, I will look into a fix. Thanks for the bug report.

    This doesn't appear to occur if a Document menu's Pause game when enabled? is unchecked - that may be a suitable workaround in the meantime.

  • OK. In v1.70 Document menus that pause the game will remain showing if the Pause menu is turned on during this time. This is so that it's display state is optional, and left to the designer.

    You'll be able to lock the Document menu using the Menu: Change state Action in the Pause menu's "ActionList when turn on" ActionList to hide the Document menu during this time.

  • Thank you Chris:):):) Ok, sounds good, I will understand better how this works when will touch all this. Btw. When do you have plans to release v1/70? Can't wait to implement this in Utopia:)

  • edited October 2019

    Ok, I found another problem. Not sure if this will be fixed too but I did what you said - I turn off Document menu Pause game when enabled? and now it's working fine, I mean I don't have that previous issue that we have discussed. BUT now I found another problems.

    I have 2 documents. First document is in the Locker called Mia Sad and second is set for the inventory item in Examine ActionList which is called Compass. Inside Compass Examine ActionList there is a Document: Open which opens second document called Test which basically show description text of this item.

    When I use any of 2 documents separately everything works good, but when I try to use them both, game start hiding my mouse and lock character movement. Please, see screenshots and video.

    Also, I have another problem. I want my character to have a speech after I will press exit button on my document. But it's running parallel with document. I found solution to create a Cutscene at the end of the Document: Open and put character speech in that Cutscene. But it's working only when Pause game when enable turned on and at the same time this affects the issue with pause menu and inventory. So as you can see here I have multiple issues that affects each other. I hope you will understand this from my videos and my super good English:).

    https://prnt.sc/pmtsxv
    https://prnt.sc/pmtszu


  • edited October 2019

    You are getting an error message at 1.19 in the first video - please show it in full.

    I'm afraid these videos are not clear in explaining the issue - I don't know what is supposed to be happening, or what clicks you're making.

    but when I try to use them both, game start hiding my mouse and lock character movement.

    What do you mean by "use them both", exactly? If the mouse is hidden, and character movement is locked, then it's likely due to a Cutscene being run. Enable the "AC Status" box at the bottom of the Settings Manager, and look at it when the issue occurs. If this is because a cutscene is blocking gameplay, it will tell you what Cutscne is causing it.

    I want my character to have a speech after I will press exit button on my document. But it's running parallel with document.

    I'm not clear - do you want to have the speech begin when the document closes?

    Pausing the game will also pause any Cutscenes that are running. It's instead better to run the speech Cutscene when you want it to run, i.e. when the document closes.

    This can be done by hooking into the OnCloseDocument custom event, see this example:

    using UnityEngine;
    using AC;
    
    public class RunActionListWhenCloseDocument : MonoBehaviour
    {
    
        public int documentID;
        public ActionList actionlistOnClose;
    
        private void OnEnable ()
        {
            EventManager.OnCloseDocument += OnCloseDocument;
        }
    
        private void OnDisable ()
        {
            EventManager.OnCloseDocument -= OnCloseDocument;
        }
    
        private void OnCloseDocument (Document document)
        {
            if (document.ID == documentID)
            {
                actionlistOnClose.Interact ();
            }
        }
    
    }
    

    (Replace ActionList with ActionListAsset to have it run an asset file instead)

  • edited October 2019

    Ok, I thought that video along with screenshots will explain the issue. Ok, let me try again:

    First Issue
    (ignore any questions regarding cutscenes - that was my second issue):

    I have 2 documents in my scene. First document opens via hotspots actionlist (called Locker), second document opens via item examine actionlist (called Compass).

    Structure of both actionlists are simple - they both have some character speeches, cutscenes (made with Engine:Control Timeline) and sounds and at the end of action tree they both have Document: Open. And of course I have 2 documents created in the Inventory menu (document tab). That's it, nothing special.

    By saying separately - I mean that If I will run the game and will run just only hotspot Locker first - everything will work fine and my document will work good, no issues. Same for Compass item - if I will run it first, it will work good, no issues.

    But, if I will run Locker actionlist first and then compass actionlist after, I will lose mouse control and character movement (it's writing in AC status that game is blocked). The issue appears if I activate Compass as second (item examine interaction). Please look again on my video, I showed you this and what I have inside both actionlists. So I am not sure what could cause such issue.

    What should happens? I should not have any issues opening both documents consistently, in any order.

    Issue:opening of both documents consistently, block game.

  • Second Issue
    "I'm not clear - do you want to have the speech begin when the document closes?"
    Yes, correct!

    Not sure where do I have to put this? What should be the sequence? So I have Document: Open as the last action in my actionlist. Should l put this event right after it and then speech cutscene or before speech cutscene? Can you please give more explanations on this or step by step if it's not hard?

  • edited October 2019

    First issue
    Again: You are getting an error message at 1:19 in the first video - please show it in full. So far as I can see, this occurs at the moment the issue occurs.

    Second issue
    The event will trigger when the Document closes. This will happen automatically. Place the code in a new C# script named RunActionListWhenCloseDocument.cs, and add it as a component to the scene. Fill in the two Inspector fields (the ID of the Document to react to, and the ActionList to run when it closes), and it should kick in automatically.

  • edited October 2019

    Sorry Chris, forgot to add images, here is this error for the first issue, not sure what it is:
    https://i.imgur.com/7eTdzhA.jpg
    https://i.imgur.com/OaSHMq9.jpg
    https://i.imgur.com/Q7Q9HDv.jpg

    Second issue - thank you, will try this:)

  • Hey Chris, for the second issue I've tried to do as you said (sorry for the nub question, scripting is not my strong side). I've created new script called RunActionListWhenCloseDocument.cs and dropped it into my scene on empty object. I've set document ID number and placed actionlist that I want to appear after I close this document (simple player speech). But it's not working. Here is the error message:

    https://i.imgur.com/RfFfXNB.jpg
    https://i.imgur.com/l1PXHX7.jpg

  • First issue
    This appears to be related to the document not having an associated texture assigned. I'll address this, but in the meantime you should be able to get around it by assigning a texture to the document in the Inventory Manager.

    Second issue
    The script is not an Action class. Take it out of your custom Actions folder and restart Unity.

  • edited October 2019

    Hey Chris, thank you, first issue - helped :smile: THANK YOU!

    As for second issue - sorry, still not working and I fully not sure that I am doing it right. I've putted that script into Assets\AdventureCreator\Scripts\ActionList, restarted Unity and that error disappeared. I've added this script to empty object as component and set document number and action list (player speech) after document close. But still nothing happens. What I am doing wrong?

  • I've putted that script into Assets\AdventureCreator\Scripts\ActionList

    I'd recommend keeping any custom scripts out of the main AC folder. Best placed in a Scripts subfolder inside your game's directory (the one created by the New Game Wizard).

    But still nothing happens. What I am doing wrong?

    It works fine on my end. Are any new errors appearing in the Console, and does your Document menu have an Appear type of On View Document?

    Try this updated script. It'll show the Document's ID when the event is called in the Console. Is this appearing at the correct time?

    using UnityEngine;
    using AC;
    
    public class RunActionListWhenCloseDocument : MonoBehaviour
    {
    
        public int documentID;
        public ActionList actionlistOnClose;
    
        private void OnEnable ()
        {
            EventManager.OnCloseDocument += OnCloseDocument;
        }
    
        private void OnDisable ()
        {
            EventManager.OnCloseDocument -= OnCloseDocument;
        }
    
        private void OnCloseDocument (Document document)
        {
            Debug.Log ("Closed document: " + document.ID);
            if (document.ID == documentID)
            {
                actionlistOnClose.Interact ();
    
            }
        }
    
    }
    
  • "I'd recommend keeping any custom scripts out of the main AC folder. Best placed in a Scripts subfolder inside your game's directory (the one created by the New Game Wizard)." - ok, did it.

    "Are any new errors appearing in the Console, and does your Document menu have an Appear type of On View Document?"

    Yes, Document menu have an Appear type of On View Document. Console says that I have 1 closed document but nothing happens after I close it:

    https://i.imgur.com/Y9aqveL.png

  • The document ID you've closed in the screenshot is 1, but you've set the ID to 304 in the Inspector.

  • Oh...Chris...sorry, my fault. Actually I used Speech Manager ID instead of Document ID. Now everything is working. HUGE Thanks Chris!!!:):):)

    Will be waiting for AC v1.70 that should fix the main issue of this post, thanks again!

  • edited January 2020

    Hey Chris:) I have one more question regarding this post. It could be quite long, sorry, but I'll try my best to explain this in details.

    Imagine that I have 2 items (Ticket and Water Filer) in my inventory and they both have examine ActionLists set to the right mouse button. So when I press on any of them it calls document with some text. After closing any of these document it runs actionlist with some player speech (I use your DocumentID script to show player speech after closing document).

    However, if I will open one document and then another without closing the previous one, your script will run the first one actionlist instead of the last one that was opened.

    Now more deeply:

    When I press the right mouse button on the item called Ticket, it will open a document with some text. If I will close this document your script will run actionlist with a player speech inside that says: "It was really sad to read it!". So everything works fine in this moment.

    The same goes for the item called Water Filter - when I close the document your script calls actionlsit with a player speech inside: "This water filter was broken!".

    If I will examine Ticket item, it will open the corresponding document. Next, if I will examine Water Filter without closing the Ticket document, it will showing me another document that corresponds to the Water Filter item which is correct. But when I close it, it will run the wrong actionlist with the wrong player's speech "It was really sad to read it!", but should say "This water filter was broken" because currently it is opened.

    I hope you understand my issue. I guess it is a problem with DocumentID script?

  • You're using v1.70 now?

    Does your Document menu pause the game when it's enabled? The first Document's ActionList should be triggered when you open the second Document - but it could be waiting for the game to come out of Pause mode to run.

    You can confirm this by enabling the "AC Status" box at the bottom of the Settings Manager.

    One workaround would be to begin both ActionLists with ActionList: Kill Actions to kill the other.

  • edited January 2020

    "Does your Document menu pause the game when it's enabled?' - did not get chance to update AC but thank you for fixing this Chris:)

    "One workaround would be to begin both ActionLists with ActionList: Kill Actions to kill the other." - thank you, I'll try this:)

    Also, I think I can just check if the first actionlists are running or I can try dialogue stop speech axction. Anyway, now I have several ways to do this. I'll try it. Thank you Chris!

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.