2008 Sep. 20

Posted by Marko under section Map Making
Trackback URI |

A first step in AI Unit Control

You'll need to have completed the previous tutorial in order to start this one. We will assume that you already know how to spawn an AI Unit on your map. The next step will be to force this unit to follow a basic path.

 

Before doing anything, we need to make sure the path we will create will stick directly on to our terrain (not applicable if you want a flight pathf for a plane or helicopter for example). Click on the Follow Terrain icon in your top toolbar as you can see below :

Now in your Rollupbar, go in the AI menu and double click on AIPath. Make a circle path by clicking on your terrain and finish the circle by double clicking as shown below :

Then make sure you disable the Road flag in the AIPath entity settings. Also, if you want to close the loop so your AI Unit goes round and round on that path, set the Closed flag to true.

 

 

 

In the Rollupbar, you will notice Sandbox2 automatically gives a name to your Path. The default here is AIPath1. You can rename it to whatever you want.

 

 

Now we're going to link our AI Unit and the path we just created. Switch back to your AI Unit by selecting it and in the Rollupbar, click on the Create button of the Flow Graph section. You will be prompted to enter a name, just put whatever you want in there (i.e soldier_path). In the Flow Graph editor, we're going to use the menu available when you right click on the grid background :

  • right click and pick Add Selected Entity.
  • right click and choose Fit Graph to View to zoom onto the graph items you have.
  • right click and pick Add Node > Misc > Start
  • right click and pick Add Node > AI > AIFollowPathSpeedStance
  • link the Start > Output to the AI Entity > Enable input as shown on the graph below
  • link the AI Entity > Enabled output to the AIFollowPathSpeedStance input called sync
  • in the AIFollowPathSpeedStance right click on <Graph Entity> and choose Assign Selected Entity
  • in the AIFollowPathSpeedStance left click on path_name. In the top right part of the window (inputs section) set the path_name variable to the name of the path you created (AIPath1 for my example)

 If you got everything right, your Graph should look like this :

If you got everything correct, you can close the Flow Graph window. AI/Physics button on the bottom part of the Sandbox window, you should see your player walk along the path your just created.