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.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
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!
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.
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?