Forum rules - please read before posting.

Pop up variables - what are they?

Hi all!

I was wondering if someone can point me in the right direction. I'm trying to understand what pop up variables are and how / where to use them, but it's not clear to me with the info available in the manual and the forums. Is this kind of variable used in any of the tutorials? It would be great to see an example.

Thanks in advance.

Comments

  • edited May 2020

    You can think of PopUp variables like a string array or enum - basically, a set of pre-defined strings, e.g.:

    "Green", "Red", "Blue".

    When setting/checking a Popup's value, you're actually dealing with their "index", i.e. which of the pre-set values it currently references. For example:

    Green = 0
    Red = 1
    Blue = 2

    They can be useful if you want a variable's value to be text-based, but don't want to have issues trying to get the name exactly correct when checking them, or be able to accidentally set them to anything.

    They can be used in many situations - even in something as simple as a door, with values "Open", "Closed" or "Locked".

    Something particularly nice about them is that - because the values they can take are pre-determined, you can use the Variable: Popup switch Action to handle all possible outcomes in a single Action.

    It's also possible to define "Popup presets", so that you can have multiple PopUp variables share the same set of values. For example, you could have several doors in your game that all use the same Popup values above using a preset.

  • Wow that was quick! Thank you Chris, I understand now. Very useful!

  • edited June 2023

    Sorry for pulling up such an old thread, but this seems too useful to pass on, i've been trying to make things easier with this, but can't seem to wrap my head around it.

    I'm using "Inventory Check" to see if I'm carrying a key.
    If that is not the case, the door wiggles and remains locked. This works.

    But i'm off after this point, how do i set the other states and have them animated?
    I have animations etc. all set up. And the proper values for the door states Locked/Open/Closed.

    How do i set the Pop Up States in the Actions and in the Animator/Component Variables to have them properly animated, and switch between locked and closed animation?

    Does someone have an example of setting those up?

  • The Variable: Set Action can be used to update a PopUp variable's value - whether it be Global, Local or Component.

    Ordinarily, a variable's value is separated from animation - so you'd need to separately run an Object: Animate Action afterwards.

    If you wanted to run a different animation based on the PopUp's value, use the Variable: PopUp switch Action beforehand (i.e. in between these two). This Action will give you an output socket for each possible value (Locked/Open/Closed), so that you can run a different Object: Animate Action accordingly.

    However, it's also possible to sync an Animator's Integer parameter with an AC Component PopUp variable. To do this, attach AC's Link Variable To Animator component and fill in its Inspector.

    Once set up, this can be used to have the Locked/Open/Closed state represented by an Integer parameter in your Animator (named e.g. "DoorState") that will update itself automatically as the PopUp variable changes value.

  • edited June 2023

    I've tried but not been able to make it work:

    I wanted it to work on Hotspot Interaction, and not drag an Inventory Item onto the door or anything like that, it should just check if i have the Key in Inventory.

    I'm failing at "Inventory check", i have the Variables on the Door Setup like this:

    • The Popup Variable "DoorState" has 3 Values "Locked" (0), "Closed" (1), "Opened" (2) and is linked to the Animator.
    • Animator with the corresponding animations.

    Actionlist and Animator is setup like this:

    https://freeimghost.net/images/2023/06/21/DoorList.jpeg

    Animator Conditions like this (couldn't figure out the locked animation, can be ignored):
    DoorOpen -> DoorClosed - Condition: DoorState = 1
    DoorClosed -> DoorOpen - Condition: DoorState = 2
    (The Bool "IsOpened" is from the Tutorial, unused in this case)

    I'm doing something wrong with the variable check, when i set the variable with a popup i can never set it to Closed.

    Where do i set correctly, and check for the "Key" and have it removed, but still have a working door.
    If it checks for the inventory, and the Key's removed, it of course breaks the check.

    I set it to Opened but how do i ever set it to make it Close again, like the "normal unlocked" Door?

    I have worked around it with two Variables

    I have setup another Variable "IsOpen" and check according to this one and set the Animation on the "IsOpen" Bool, but that is not the correct way to use PopUp Variables.
    I wouldn't need it at all, if i'm using two anyway right?


    https://freeimghost.net/images/2023/06/21/workaround.jpeg

    It is probably super simple, but i don't get it after hours of doing it.

  • Two variables shouldn't necessary - since the PopUp records the open/closed state as well as the locked state.

    It's also not necessary for the (1) Variable: Check Action in your first screenshot - since it's checking the PopUp variable again. You can reroute the (0) Variable: PopUp switch "Closed" output to (2) Variable: Set, and the "Opened" to (3) Variable: Set directly.

    As for the variable/parameter: have you attached a Link Variable To Animator component? If so, temporarily disable/remove it and just focus on the variable's value, ignoring the animation of the door.

    Keeping the Variables Inspector open at runtime, the ActionList chain in your screenshot should update the PopUp variable's value from Locked -> Opened -> Closed when clicking multiple times (provided the Key is in the Inventory to begin with). Is this not the case?

  • Indeed it works perfect, thank you for clearing up that blockage.
    Animator and everything else is great aswell.

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.