Forum rules - please read before posting.

[SOLVED] Issues I'm having with variables and Dialogue System

edited August 2014 in Technical Q&A
I'm having some strange problems right now related to variables and my menu system, maybe someone knows what's going wrong.

I'm trying to run a cutscene following a variable change. It's a local variable, and the way I change its value is when the player opens a menu and clicks a specific button, a script runs that says: LocalVariables.SetBooleanValue(0, true), and closes the menu. That's when the cutscene should kick in, but it doesn't.

I then tried to bind that same line of code to a keypress to see if it was a problem in the map menu logic, but no luck there. Even putting it as a global variable instead didn't work. The only way it works is if I change the variable value with another cutscene. But that won't do because it needs to trigger from that menu script (for reasons).

-

Then, problem 2: In the scene directly following this one, I have a problem with another menu. The menu contains an inventory grid, and clicking on each item runs an ActionList that puts a bit of text on a label in that same menu. But when I open that menu in this scene, I cannot click on any of the inv items, nothing happens. To complicate things, the EXIT button in the corner of the menu DOES work.

Also, when this menu is closed, there is a little notification badge on it telling you if there is new information (a new item in the grid, basically). I do this by checking against a (global) variable and displaying its value on the badge label, something that works fine in the scene I mentioned above, but doesn't work in this scene, even though I change the value from a cutscene here! It used to work in earlier builds, I know that much. The rest of the cutscene plays just fine, but no badge shows up after it, and like I said, the related menu is unresponsive.


I hope it is somewhat understandable what I tried to explain here ha.

Comments

  • 1)
    The "On Variable change" Cutscene won't be triggered if you manually change a variable through script - only when using the Variable: Set Action.  If you must call a script, you can trigger the Cutscene through script as well:

    GameObject.FindWithTag (Tags.gameEngine).GetComponent <SceneSettings>().cutsceneOnVarChange.Interact ();


    2)
    You'll need to back up a bit, because I don't follow this "menu closed" business.  You're saying it all works in one scene but not the other?  Could be to do with whether or not the game is paused or not.  When the game is running, look at the PersistentEngine gameobject's StateHandler component and compare the Game State value between the two scenes.  That could offer a clue.
  • Ah great that fixes #1.

    About #2, that IS a bit of a complicated matter yes. So: I have a menu that has an inventory grid and a text label. Clicking an inv item runs an ActionList that puts a string of text on the label (each item has a different description). The ActionList sends a message to a script that has all the strings (kinda like reading from an XML).

    Opening that menu puts the game in the dialogue gamestate, and closing it returns it to normal state.

    In scene A, I open that menu and clicking the items works fine. In scene B (and C), opening the menu works, but none of the items do anything when clicked. Only the Close button still works.

    So that's issue #2.1, in a way.

    #2.2 is that I have a persistent onscreen button to open the menu described above. On that button (a seperate menu in itself, really) is a label that displays the number in a global variable (the amount of notifications). If the variable is zero, the label is hidden. After a conversation I have in room B I run a cutscene that increases the value of said global variable. This should mean that the label appears on screen (like it does in room A), but nothing happens.

    I tried looking at the PersistentEngine's StateHandler, but the dropdown describing the game state does not update while I run the game, so I can't tell. Is there another way to check? Also, while the menu with the inventory is open I can still see the cursor menu I made to appear over hotspots hover behind it, is that a tell-tale sign of something?


  • Ah I've fixed problem 2.1! The menu had a Constant ID script on it that was set to Manual, and it had a different ID between scenes A and B & C, which confused the ActionList that was referring to it by ID to control the menu elements. I made it all the same number and now it works again. Only problem 2.2 remains.
  • If it's not displaying, that could be due to two things:

    1) The menu with the "Variable label" is not turned off
    2) The "Variable label" element is hidden
    3) It's displayed underneath another menu or element

    How are you getting the label to disappear if the Variable is zero?  Perhaps that ActionList needs to be re-run.
  • This is the code that handles the label (it's in a script on a gameobject that's present in every scene):


    MenuLabel badgeDossier;

    void Start() {
    badgeDossier = (MenuLabel) PlayerMenus.GetElementWithName ("Dossier Button", "Notifications badge");
    }

    void Update() {
    //see whether there are any notifications, and if so, display the badge:
    int notificationsDossier = GlobalVariables.GetIntegerValue(0);

    if (notificationsDossier != 0) {
    badgeDossier.isVisible = true;
    }
    else if (notificationsDossier == 0) {
    badgeDossier.isVisible = false;
    }
    }


    In the cutscene mentioned above, the inventory items that that cutscene is supposed to add also don't get added. Up until the map element actions it works, the rest apparently doesn't.

    Perhaps it has something to do with Dialogue System For Unity, this cutscene is run at the end of a conversation.
  • Open the Cutscecne up in the ActionList Editor window - do the wires connect up properly?  The Menu: Change state Action should never not run actions that follow it unless told to.
  • edited July 2014
    Yep, they're all set to continue in one straight line. I tried moving them to the top of the queue in the cutscene, didn't work, so it's not an order thing. I also tried changing the variables with a Object: Send Message instead, didn't work.

    I made a debug menu that only has a label with the global variable value on it, and that doesn't change after the cutscene has run, so somehow the variables and the inv items are unreachable.

    Perhaps a related problem: whenever I open the cutscene in the inspector, all the Add Inv actions say they are adding item 1 (which I already have). Only when I fold out each individual action does their title update to reflect the actual items it should be adding (3, 4 and 5).
  • The label shouldn't affect the action inside, but just to be sure: does keeping the action expanded BEFORE it's run correct the issue?

    What do you mean by using the Object: Send message Action to change the variables?  I'm not quite clear on how this Cutscene is being run.
  • Thanks Chris, keeping the action expanded doesn't fix the problem sadly.

    Well what I meant was: initially I used Variable: Set in the cutscene to increase the integer by 3 (as in: 3 new notifications). When that didn't work I tried to write a function instead that's basically:

    void changeVariable() {
    AC.GlobalVariables.SetIntegerValue (0, +3);
    }

    and trigger that with an Object: Send Message to a gameobject in the scene. But that didn't work either.

    It HAS to be something about the scene itself, this method works fine in all other scenes, but I can't for the life of me figure out what is causing it to not update the global variables and inventory items here, while still executing the rest of the actions in the cutscene...
  • After further consideration I think this may also be a Dialogue System For Unity issue. When this problem occurs it is when I've triggered a cutscene from a Dialogue System conversation, and I know that plugin syncs items and variables between itself and AC, so there's probably something going wrong there. I've sent an email to Tony, we'll see if he can find the cause.
  • Fixed! Tony updated the AC support package for Dialogue System, should appear in the next release on the Asset Store to fix this. It was a syncing issue between that plugin and AC's variables and items.
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.