Tutorial #11: Mass Control

You might be wondering how to control large groups of bots with one command.  With our system, this is very simple!

All you have to do is create an empty game object, name it something like “Enemy Team” and add your bots as child objects.  Then, create another empty gameobject with a PlayMaker FSM, and loop through each child from “Enemy Team” and change their CurrentCommand in real time.

How to set commands in real time? Look at the Real Time Command demo scene.  That scene shows how to set the real time command for one bot.  All you have to do is do that for each enemy bot you loop through.

In a future update, we may include demo scenes for swarm A.I., but we didn’t include one because it is very easy to do it yourself:


STEP 1: Create a ton of bots and place them as child, under a blank GameObject.



STEP 2: Create a new blank gameobject, name it something like “Swarm FSM”, and add an FSM:



STEP 3: You loop through each child of the main gameobject, store the child bot inside “Current Bot”, then give a command to that bot.  Remember to disable the Movement FSM first, then give your command, then enable the Movement FSM.  This resets the Movement FSM and tells is it to process your new command.


HINT: Do you notice what is wrong here? We on purposely made some mistakes here to show you what you should avoid doing. Many users forget this and are left wondering where the errors are coming from.


STEP 3b:  Fix the above layout after learning about the following issues:



Please remember these issues as you edit FSMs in your projects later.  Sometimes, a small careless mistake can cost you hours in debugging!

And with that, YOU’RE DONE! This is a basic example and a general outline to give you an idea what you should do.  The possibilities are endless, really.  Since in this example we gave the command of “GUARD_CHASE”, the bots will do nothing until there is an enemy in sight.  Then they will either chase or shoot him.