Wiki

Case Status
Log In

Wiki

 
Home ยป Activate Children Using an Arr…
Index
Navigation
Community Wiki

Activate Children Using an Array

This Array example shows how to activate children using an array of On/Off values.

This article assumes a basic knowledge of the PlayMaker editor (how to add states, actions etc.).

Import ActivateChildrenExampleScene.unitypackage  into a PlayMaker project and open the included scene.

The example uses Array Get Next, Get Child Num, and Activate Game Object actions with a simple loop.

 

Bool Array

We use a Bool Array called ActivateChildren to store the desired On/Off activation state for each child.

You can set the array size to the number of children and set array items to true/false.

 

Array Get Next

The Array Get Next action lets you quickly loop through an array.

Note that we store the current array item value in an activate variable and also store the index.

In the loop we go to an Activate Child state. 

 

Get Child Num

The Get Child Num action gets a child by its index then Activate Game Object uses the activate state we got from the array.

 

Result

When run, the FSM loops through the ActivateChildren array and activates each child using the values in the array.

When all items in the array have been used, it goes to a Finished state.

 

Conclusion

There are always multiple ways to achieve a goal in Unity/PlayMaker. Explore the Array Actions and you'll find other ways to use arrays.

There are also many shortcuts for common scenarios available on the PlayMaker Ecosystem

 

 

Tags:

Last modified on 12/11/2019 6:37 PM by User.

  • RSS Feed