Forum rules - please read before posting.

Creating Asset Actionlists with Variable Component parameters (not working, or planned feature?)

Hi there!

Every day I'm delving a bit deeper into AC, it's really a valuable tool :)
Yet today, I was trying to solve this problem:

I have multiple "Vase pedestals", and each one of them holds a Component Variable holding the Popup version of the vase that we're putting on them.

As long as I had only one pedestal, I had everything set up as a scene actionlist, so everything was fine.
I could put/take each vase, and the character (and an external observer object to check if the puzzle was solved) acted appropriately according to the kind of vase that was put onto it.

I decided I wanted to just reuse the same actions, dialogues, etc. so I converted it into an asset, expecting to simply pass the Variable Component and the Pedestal Object as parameters.

Yet, I can't!
I can set a parameter to be a Component Variable, but the Variable: Pop Up switch only lets me pick scene objects. (there's also another action that is missing Variable component support, but can't remind it right now)

It's a feature that is intentionally missing due to it being technical impossible, a simple oversight, or a feature planned for next update?

Here's a sample picture:
(now broken since the popup switch is not backed by any list)

Of course I could duplicate the scene Actionlist "in the brute and easy way", but would be cool if it was possible to handle such case.

Is it a missing feature? Am I doing something wrong, or, maybe, did I forget to do something for the Component Variable parameter dropdown to appear (gonna check the source right now).

Could you please help me? Any help is appreciated :)
Thanks.

Comments

  • I remembered about the other issue I had, or have no explanation for:

    "Placeholder: bool"?

    Isn't possible to choose the expected type of variable, and cast the popup to int?

    The screen above is about another part of the puzzle that I really wanted to use parameters/Variable Component for, but I"m now (unless I decide to do some pure coding accessing a few AC variables) forced to duplicate the same interaction for each vase size (3) multiplied the number of pedestals (currently only 2, but I may need more in the future).

    With parameters I could have only done it once. Am I missing something in this process?

  • edited August 2019

    Certainly the intent with the Component variables and parameters systems is to allow puzzles of the kind above (at least so far as I've understood you) to rely on recyclable ActionLists rather than interaction duplication.

    I suspect this omission from the Variable: Pop up switch Action is an oversight - I'll look to remedy it in the next AC release. PM me if you'd like to be involved in testing.

    Isn't possible to choose the expected type of variable, and cast the popup to int?

    The placeholder value is currently set by unsetting the parameter field, and selecting a variable of the intended type. I shall see if adding a dedicated "type" selector field is viable once a parameter is assigned.

  • Sounds great! I really couldn't figure out what was wrong!

    Not sure if this is appropriate for this topic but the problem I was trying to solve, is just a simple puzzle:

    • There are 1 or more pedestals (hotspots)
    • There are 3 types of vases to be put on. The pedestal can also hold no vases at all.
    • An inventory interaction (dragging the item on the pedestal) removes the inventory item and sets the hotspot to hold a certain type of vase.
    • Picking up the vase on the pedestal removes it from the pedestal (hotspot), resets the hotspot, adds the appropriate vase type back into the inventory.

    Externally, an Observer element checks if the vases on the pedestal match the correct combination.

    How would you implement it?
    Local variables don't seem to work with me when using them as parameters (So that each pedestal passes a different local variable to an ActionList Asset) - not sure if it's a bug or what - I've been able to break (errors in the console) the Variable Action several times when switching back and forth different variable sources.

    I thought about Containers, but I should be able to pass them as parameters.

    I either need to create 1 or 3 inventory interactions for each hotspot: 1 to put the small vase, 1 for the medium, 1 for the big one.
    I tried to add 3 different Set Interaction Parameters, one for each interaction, but, since I also have a -look at- interaction on the hotspot, the Set Interaction Parameters doesn't show up with the correct parameters throwing an out of array index error. So I can't do that way.

    Currently I can't think of a way to implement the puzzle (which is actually a pretty common one) only using native AC components.

    Do you have any clues on the best way to do that?
    (having a variable check able to work as a "switch" statement (without the overhead of using named values like in Switch Popups) with a custom number of exits would be useful. I currently have a chain of nested "IF"s to check for several values of ints (but being able to do that with inventory items or other types would be useful as well)))

    Any suggestion is welcome :)

  • How would you implement it?

    I wouldn't use Containers. Is this for a 2D game, so that you're only dealing with sprites?

    First of all, I'd create an Animator on the Hotspot's graphic that can be used to swap out the displayed vase only using animation, so that the Object: Animate Action can be used to control what's shown.

    If picking up a vase again is a case of running a "Use" interaction on the Hotspot, probably easiest to give each vase it's own Use interaction, and use the Hotspot: Change interaction Action to make sure only the appropriate Use interaction is enabled at any one time.

    When a vase is placed, it's then a case of using a series of this Action type to disable all but the appropriate one. What you can then do is run a separate ActionList that examines the state of these interactions and updates the animator accordingly. No need for a variable specifically here. The Hotspot: Check interaction can be used to determine what interaction is enabled and what isn't.

    The advantage of placing this in a separate asset file is that you can then have this run when the scene begins - in case you want to e.g. set up different pedestals with different vases by default. To do this, attach an "ActionList Starter" component and link up the ActionList asset to run on start.

    When it comes to running "generic" ActionLists as Hotspot interactions, it's often the case that you'll want to set many parameter values in bulk. To do this, you can attach the "Set interaction parameters" component, which can be used to set parameter values according to which Hotspot interaction was clicked in order to run the ActionList.

    I've been able to break (errors in the console) the Variable Action several times when switching back and forth different variable sources.

    If you encounter a bug, please provide details with steps to recreate in a separate thread.

  • Thanks for the clarification.
    Not using variables feels a bit... unusual to me but it's a nice workaround, I wouldn't have ever thought about switching interactions - at the moment when the character checks the pedestal, it uses a popup switch with the Variable Component to determine the phrase to say.

    It's a 3D game, and I initially have plenty of vases scattered in the room, which self-hide, all using their prefabs but using a single asset actionlist with 1 param: the VaseType (an inventory item) to give the player.

    when the player drags a vase onto the pedestal (inventory interaction), I was thinking about checking for the presence of other vases, and instantiating/destroying the appropriate prefab at runtime according to the inventory Item passed by (or, by setting the Interaction params with the appropriate prefab, according the inventory Item).

    I'm not sure if it is safe to instantiate/destroy the aspect of a vase in this way.
    Probably putting all visual aspects in place and only showing the appropriate one is a better idea.

    I don't know if istantiating a prefab in this way is going to mess with the constantID system (Using the Action Object.Create allows getting a reference of the currently instanced object?).

  • edited August 2019

    If you encounter a bug, please provide details with steps to recreate in a separate thread.

    Done!
    https://adventurecreator.org/forum/discussion/9081/issue-s-index-out-of-range-and-variable-pop-up-switch-action-is-referencing-a-var-not-exist#latest

  • edited August 2019

    I personally prefer to do as little runtime instantiating/destroying as possible, and that's just with Unity in general.

    Spawning multiple instances of the same prefab in AC only gets tricky if you wish to save their presence. Saving a spawned object's presence in a scene is typically done by attaching a Remember Transform component, checking Save scene presence?, and placing the prefab in a Resources folder with a unique name. (See the Manual's "Saving asset references" chapter for more on that last bit.)

    Having multiple instances of the same prefab type makes things a little more tricky in that you have to assign a value in this component's Linked prefab ConstantID field - though this is generally the same value as its own Constant ID.

    However, even in 3D you can still keep all vases as children of the root "pedestal", and control their visibility through animation playback. You can then use a single Integer animator parameter to determine which is shown. This would be my choice of approach.

    You could even rely on this animator parameter's value, and not a variable or the state of the Hotspot's interactions, to determine the current state of things. A custom Action could be written to check its value both upon startup, and when the player interacts with it. Attaching the Remember Animator component to an Animator allows you to locally set an Animator's starting parameter values.

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.