Forum rules - please read before posting.

Global variable set to true being ignored

Hi all and Chris (again).

I'm having another issue and really stumped.

I'm using Unity version 2018.3.11f1
AC v1.68.2

I have a number of global variables that I set to true after certain interactions are performed. However, when I select a different inventory object to examine first and then try and drag the correct inventory item to the specific hotspot it appears to ignore a key global boolean variable. The different inventory item is a dependency for the correct item to be used.

I'll break it down:

  1. Open Inventory menu, Cast a spell via the inventory item's 'use action list'. Dependencies are carrying specific item A and B. A short animation plays - this works fine - there are other variables but these don't appear to have a negative effect and work fine.
  2. Then set the global variable to True (Bool).
  3. Item A is now needed for the next action list. I drop and drag Item A onto the specific hotspot, I have a variable check in place to ensure that the expected cutscene runs when it is set to true. I also need to ensure that the player is carrying both item A and item B. I also have a check that the item selected is item A - this is fine.
  4. However, when I examine or use item B first and then drag and drop item A on the hotspot, the global variable I set previously to true is ignored.

I have my inventory set up as follows:

  1. Open inventory menu
  2. Examine item - actions are - close Inventory menu - player says line - open Inventory menu
  3. Use item - actions are - close Inventory menu - drag and drop item onto hotspot - action list runs

Item A = Future Miracle Grow
Item B = Historic Weed Killer

I've tried to include the main actions within the action list to view. The expected result is for Action 0 to lead to Action 1 and then to Action 4.

I'm really not sure what I can do to resolve this so any help as always is very much appreciated.


  • So it's "Cast TT Spell" that's the problematic one?

    From what I gather in the screenshot, this value being ignored would result in Action #7 running. Is this the case?

    One way to confirm exactly which Actions are being run is to toggle comments on your Actions via the cog icon, write something simple in the yellow box, and then have them show up in the Console by checking Print Action comments in Console? at the bottom of the Settings Manager.

    Does examining Item B only cause the issue, or does this also occur with another Item C? If B only, what Actions are run exactly?

    If you check Show realtime values? in the Variables Manager, you can view their values while the game runs - is the variable correctly set at all times?

  • Hi Chris.

    Yes correct Cast TT Spell is the problematic bool variable.

    So I followed your instructions and tried the same steps using an additional inventory item and the same issue occurred. It only seems to happen after I've cast the TT Spell. If I examine inventory beforehand and then drag the correct object onto the hotspot, the correct cutscene plays.

    The screenshots below display the comment toggles in the console. The second screenshot highlights where the issue occurs. I added comments to early actionlists to see if anything odd happens. It's weird as I've clearly set the Cast TT Spell to true.

    Is there anything I'm missing do you think?

    Many thanks

  • But what of the variable itself? Is it displayed as "True" in the Variables Manager at the time this occurs?

    A feature of Action comments is that they can also contain variable tokens. Inside the comment for Action #1 (the Variable: Check), try placing:

    Value is [var:ID]

    (Replacing "ID" with the ID number of your "Cast TT Spell" variable, as shown to the left of it's name in the Variables Manager).

    What then? That should help narrow the source of the problem.

  • I am having a similar issue, where a local variable is getting reset instead of staying to what it has been set to via Action list.

    I think the issue is actually Dialogue System. I removed the Third Party: DS Start Conversation Action and the variable stayed to what it was supposed to be set at.

    I need to use Dialogue System though, I'm not sure why it is resetting variables. It resets them when you use the End Conversation action I think.

  • Update: I solved it by unticking the "Back to AC (On Conversation End)" Sync Options. These overwrite AC variables.

  • Thanks Chris, that's really useful.

    Ok, so it says the Value is False

    So I also watched the Global Variables change from False to True and vice versa in the Variables Manager while playing the game.

    Directly after I examine an inventory item -

    Open Inventory - Examine Item, Close Inventory - Say Line - Open Inventory

    the "Cast TT Spell" variable switches to False. Very odd.

    I checked the InGame menu I set up - this is a Satchel image, when pressed it opens the Inventory menu. And I also checked the Inventory menu, nothing unexpected in either.

    Still really stumped.

    Many thanks

  • Have you seen @Deckard_89's post above about the possibility of this being Dialogue System-related?

    If the Variable itself is being set to False somehow, we may be able to do some debugging to find the cause. Open up the script file GlobalVariables.cs, and find line 270:

    var.val = 0;

    Immediately above it, insert the following:

    Debug.LogWarning ("Set bool '" + var.label + " to false");

    Then run the game, and check the Console for a warning that reports the variable being set to false. If it shows at an unexpected moment, select the full message from the Console (including the script references beneath it) and paste it here.

  • Sorry @Deckard_89 I completely missed your posts. Your suggestion has worked so thank you! Ah I've been stumped on this for a while now.

    Everything is working as expected. I presume that's the correct setting then for instances like this and not a bug.

    I am so happy!

    And thank you Chris for bearing with me and for your help. I'll certainly use your recommendations if I run into similar problems. Useful tips.

    Have a great day.

  • If it helps, the order of events is:

    When a DS conversation starts:

    • If Copy AC Variables To Dialogue System is ticked, it copies the values of all AC global and local variables (e.g., "Cast TT Spell") to an equivalent DS variable (e.g., Variable["Cast_TT_Spell"]), creating the DS variable if it doesn't already exist.
    • If Copy AC Item Counts To Dialogue System is ticked, it copies the item counts of all AC items to an equivalent DS Item element (e.g., Item["Future_Miracle_Grow"].Count).
    • If neither checkbox is ticked, it doesn't do either of these.

    When a DS conversation ends:

    • If Copy Dialogue System to AC Variables is ticked, it goes through all AC global and local variables and sets their values to what it finds in the Dialogue System.
    • If Copy Dialogue System to AC Items is ticked, it goes through all AC items and sets their counts to what it finds in the Dialogue System.
    • If neither checkbox is ticked, it leaves AC's values untouched.
  • @PixelCrushers and Chris and everyone - hello all.

    Hi all, not sure where to post this as not sure whether the above change in settings is to do with my new issue or if it's an AC thing. So apologies if this is not an AC issue.

    I'm finding that the AC fade music action prior to a scene change or when dialogue is fast forward, it just stops the music dead now. I can live with it but it sounds very abrupt in places. If it's a DS issue, I'll post a new thread in your forum but I think it might be connected?

    This is my current AC bridge

  • Hi Caroline,

    I don't think it's Dialogue System-related, but if you'd like to send me a reproduction project I'd be happy to check it out.

  • So you're switching scene while a new music track is in the middle of fading in? If you're using the Sound: Play music Action, then a scene-change shouldn't interrupt the music, unless your new scene has new music to play, or the scene-change is the result of loading a save file.

    What are your AC and Unity version numbers?

  • edited August 2019

    Hi Chris.

    Did you need me to start a new thread for this, happy to do so.


    Unity 2018.3.11f1
    AC 1.68.2

    Camera will switch and play a cutscene where you can click through (fast forward) the dialogue. During the custscene, a piece of music will play on a loop. Expected result is when the dialogue finishes, the music fades out and stops and the camera switches back to gameplay.

    I'll be fast forwarding through dialogue (using DS) where a piece of music is playing (on loop). At the end of the conversation the music should fade out and stop but it just stops abruptly. 'Play Music', 'Music Storage Window', 'Method Stop', 'Fade out time 3 seconds', 'Wait until transitions ends = Yes'.

    So it appears to ignore the 3 second fade out.

  • A music playback issue introduced in v1.68.0 has since been fixed in v1.68.3. Try it with the latest release, and if there's still an issue - yes, let's start a new thread and let me know the result of running the same Action from a separate Cutscene manually via the "Run now" button in its Inspector.

  • Ah that did the trick. I did wonder if it was that after reading your release notes. Thanks Chris, much appreciated as always.

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.