Forum rules - please read before posting.

Best way to manage flow?

Some adventure games are not linear and take place in a single environment. This opens up the question of flow/sequence management.

A simple example is a walk-through trigger. When you walk into a trigger, a monkey could jump out of a box.
But I don't want that happen all the time, so I check a global variable - which sees which phase of the game the player is.
Now when I walk into the trigger, the monkey jumps out only if the global variable playerPhase = 5.

Easy enough. But what if I have 50 triggers scattered throughout the level? And each of those has to check 20 playerPhase values to determine what they should do and how they should react if the player walks into them during various phases?

Is the way to manage them really to go into each ActionList for each trigger and look at each branch for if playerPhase = 1, 2, 3, etc.?

Its difficult to manage because I don't get a high level view of the game. I'd like a way to see the branching flow of the entire game - what triggers, events, etc. are available to the player when their playerPhase = 8? That could mean the player found a special sword or talked to the right NPC, so now they are in the 8th phase of the game. No longer will that monkey jump out of the box, but a different trigger, that did nothing before, plays music. Right now, it seems like I have to go one by one through all ActionLists and dig in to find out what each one does at Phase = 8.

I hope this makes sense.

Would my solution be to have a "master" ActionList, which acts as the tree for the entire game, and trigger sub actionlists based on it? Or should I just use something like PlayMaker to handle the overall logic as one tree for the entire game? Or maybe even BehaviorDesigner so it follows an actual branching structure? It seems like when you have more than a few places needed for variable checks, its going to get really disorganized and hard to edit.

Just want to make sure I'm not missing something included in Adventure Creator that is straight forward or a best practice I haven't seen before I try to think up alternatives.

Thanks!

Comments

  • edited January 30
    • PopUp variables, rather than Integers, are better suited to storing a discrete number of values. They can firstly have labels attached to each value (for easier readability), but can also be used by the Variable: PopUp switch Action to allow for all possible output values to be processed in one - rather than needing a separate Variable: Check Action for each outcome. PopUp values can also be assigned from presets, so that you can recycle their values.

    • It's possible to locate all references made to a particular Variable via the cog menu beside its definition in the Variables Manager / Variables component Inspector. This is useful if you want to find e.g. all ActionLists that depend on it.

    • A "master" ActionList could indeed be used to set either a "master game state" variable, or enable/disable Triggers etc, based on other things like inventory count, other variables, etc.

    • You're not limited to the provided Actions to manipulate Variables. You can also rely on custom Actions, and custom scripting, to get and set their values. Global and Component variables can also be linked externally - either PlayMaker or a custom script. Once set up, such a link is automatic - so you can e.g. set a value through PlayMaker, and it'll be reflected in Variable: Check Actions. For more on this, see the Manual's "Variable linking" chapter.

    • Component variables and ActionList parameters also offer powerful ways of compartmentalising game logic:

    Taking your Trigger example, let's say all Triggers in your game can either do nothing, show a monkey, or play some music. This might not be suitable for your actual needs, but here's one avenue you could go down:

    1. Put the Trigger, and whatever GameObjects needed for the monkey, into one shared hierarchy so that it can be prefabbed.
    2. Attach a Variables component to the Trigger and define a new PopUp variable. Create this from a preset, so that values can be shared elsewhere without needing to reference the variable itself. Give it the values 'Do nothing', 'Show monkey', and 'Play music'.
    3. As ActionLists cannot exist in prefabs, you'll have to rely on ActionList asset files - so switch the Trigger's Actions Source field to Asset File and create a new asset.
    4. In this asset, check Use parameters? and define a new Component Variable parameter.
    5. Create a Variable: Pop Up switch Action, set the Source to Component. Then override the Variable field with this parameter.
    6. Once overridden, you can assign a Placeholder preset to determine outcomes based on a PopUp preset - set this to the same one associated with the one defined in 2.
    7. Wire up the different outcomes accordingly - so e.g. "Play music" results in the Sound: Play music Action. (As "Show monkey" involves animation etc, probably easiest to have that just show a Dialogue: Play speech Action for initial testing.
    8. Go back to the Trigger prefab, and attach a Set Trigger Parameters component. This allows you to set the value of each parameter defined in its ActionList, at the time it is run. This should now display a field for the Component Variable parameter you defined in 4. Assign this as itself (the Variables should be attached to the same GameObject as this component / Trigger component).
    9. It should now be the case that you can place down any instance of the Trigger prefab and set its own Component PopUp Variable independently, and this value will determine what happens when run. Note that there is currently a bug whereby this doesn't occur if you click Run now - it has to be an actual Trigger detection. I'll address this.

    Either way, you now have the ability to locally set the state of each Trigger, and have each Trigger behave indepently from one another, by simply changing its own PopUp variable with the Variable: Set Action. This can be done from a "master" ActionList that you described above. Alternatively, as I mentioned above - you could also link these values to e.g. PlayMaker.

  • Thanks for the feedback, Chris. Very helpful!

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.