An introduction to parameters

Over the course of a game, it's often the case that the same series of Actions will need to be performed, albiet with slight differences.

When the player picks up an object in the scene, for example, we want the player to move towards it, the object to be made invisible, and the item will need to be added to the inventory. We'd have to create the same three Actions for each item in our game - and if we later decided to add more Actions, we'd have to go through each set and amend it one-by-one.

ActionList parameters allow us to create these three Actions just once, and make slight tweaks to them each time they're run. This may not sound like much of a difference, but this is just a basic example: when dealing with more complex sequences, parameters can be a life-saver.

In keeping with the above example, let's create a parameterised ActionList that we can call every time we want the player to pick up an item.

Begin by creating a new ActionList asset by choosing Assets -> Create -> Adventure Creator -> ActionList from the top toolbar.

In the Project window, rename this new asset Take item.

In the asset's Inspector window, create a Character: Move to point Action, checking both the Is Player? and Pause until finish? boxes. Leave the Marker to reach field blank.

Next, create an Object: Visibility Action, and set Visibility to Invisible.

Create a final Inventory: Add or remove Action, and set the Add or remove field to Add. Don't worry about the Inventory item field for now.

Notice that we've so far ignored the crucial field in each Action, for example the Object to affect. That's because we'll be setting these dynamically using parameters.

We'll give each Action one parameter, so we'll need three of them. In the Asset properties box, check Use parameters?, and click Create new parameter 3 times.

Three parameter rows will now be listed. We can give each a name, and choose a type. Our first parameter will determine the Marker that we'll make the player walk to, so name it Nearby marker, and leave it's type as Game Object.

Our second parameter will determine which scene object to hide, so name it Object to hide, and leave it's type as Game Object.

Our third parameter will determine which Inventory item to give the player, so name it Item to add, and set it's type to Inventory Item.

Now that we've defined some parameters, the Actions below have expanded so that we can assign them. If a field label appears twice, it means that we can override it with a parameter. If we don't choose a parameter, the field can be set as normal.

Going back to our Character: Move to point Action, set the Marker to reach to Nearby marker. Notice how the second field label disappears once the parameter has been set.

In the Object: Visibility Action, set the Object to affect to Object to hide.

In the Inventory: Add or remove Action, set the Inventory item to Item to add.

Our parameterised ActionList is now complete. Though we can also apply parameters to scene-based ActionLists such as Cutscenes, the added bonus of using an ActionList asset is that we can call upon this ActionList from any scene.

To use this asset, simply use the ActionList: Run Action from any other ActionList. Set the Source to Asset File, set the ActionList to Take item. The Action will recognise that Take item contains parameters, so check Set parameters? to expose fields to se their values.

We can now choose a Nearby marker for the player to walk to, the scene-based Object to hide, and the Item to add to the player's Inventory.

These fields will only be set as such for this time only, and we can re-use this asset to affect a completely different set of objects each time.

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!