Getting Started - IsaacMulcahy/RPG-AI-SYSTEM-WIKI GitHub Wiki

How to get into the Project

  1. Bring up the 'Package Manager' in Unity (Window -> Package Manager - Found along the top left top bar in Unity)
  2. Search for CIVIL-AI-SYSTEM and select it from the list
  3. Click 'Import' (Bottom right of the Package Manager window)

Running the Example Scenes

Setup of these scenes needs one step on the first time of opening them.

  1. Open the Example Scene
  2. Open the 'AI Manager' (Window -> AI -> CIVIL-AI-SYSTEM -> Overview Manager)
  3. Within 'Performable Actions', click 'Fix Scene'
  4. Save the scene
  5. All good to go!
  6. Let us know how you find it and give us a Review on the Unity Asset Store

How to setup

Setup of the system is straight forward, using the Overview Manager.

  1. Within 'Setup AI in Scene' section have all tick boxes ticked and click 'Create and Add Assets to Scene'. This will add all the objects required in the scene to be added (Excluding the houses and workplaces)

  2. Then add in a Region using the 'Region Management' section (located a bit further down from the setup section), the text box to the left of 'Create Region' is for the name and is required, 'Create Region' will add it to the scene.

  3. Add in your NPC character Game Object and click 'Setup object as NPC' and save this as a prefab and remove from scene.

  4. Add the NPC prefab to the local Region Character Pool, if Civil Jobs is set to 'NONE' then it can be used for all Jobs

  5. Add in your houses and workplaces (Both need colliders, can be triggers for the region to find them)

    5.1. These are both made similarly to the NPC, that being within the Overview Manager has a template you can apply to any gameObject to setup them up.

    5.2. Move the entrance center to be level with the Nav Mesh

    5.3. Add a collision of some sort to allow the region to find the House/Workplace

  6. Add jobs to the workplaces, found in JobData

  7. Increase the Resident max within the House to at least 1

  8. That's everything within the Scene setup except the Nav Mesh (see below) which is unique to this product and ready to receive your defined behaviors

Simple Setup of Nav Mesh in Unity

  1. Set objects which the AI should be able to walk on as 'static' (top right box in the 'Inspector')
  2. Bring up the Nav Mesh window (Window -> AI -> Navigation)
  3. Select the 'Bake' tab
  4. Press 'Bake' (This can take some time)
  5. When on the Nav Mesh window tab you should see blue areas showing the areas where the NPC's can move

Get Started making AI behavior

Let's create our first Job, in this example we will make a Woodcutter Job (video: ). This assumes you have Setup the system for the Scene.

  1. Bring up the 'Flowchart Editor' (Found Window -> AI -> CIVIL-AI-SYSTEM -> Flowchart Editor)
  2. Within this screen it allows us to design the behavior of our NPC's
  3. Right click on the window space and select 'Job', this will create a Job Node which has a number of characteristics
  4. Change the 'Name'of the Job Node to 'Woodcutter'
  5. Then create a second node but this time Duty called 'Collect Wood'
  6. Connect these nodes by click and dragging from the 'Exit' to the 'Entry' section of the nodes
  7. Create a Task called 'Gather from Tree' and link to the Duty 'Collect Wood'
  8. Now we can create a Method and we will call it 'Find Tree to fall'
  9. The next step is to use an Action to find the tree, create a new node Action, within action characteristic select 'LOCATE' and change the 'Item Needed' to 'TREE', tick 'Set Item in Use' along with ticking 'No Reset of Item in Use' and connect it to the 'Find a Tree to fall' Method
  10. Create another action but this time create it with the action characteristic being 'IDLE' and the 'Set Item in Use' ticked
  11. Now we need to add in a wait time and an animation for the felling of the Tree using the Requirement System, this is done by clicking on the button within the parent node ('Find a Tree to fall') 'Connections' section, the child node which is an Action Node 'Idle' will have an id, click on the button 'No' next to the child node id and you'll get a new popup providing three options, 'Delete', 'Animation' and 'Wait Time', we want to add an animation in and give a wait time so we will update these fields
  12. Now that this is all done Save the AI Flow and call it 'Woodcutter'
  13. Go back to the Settings and change the 'Import Job System Data' selection to 'Woodcutter'
  14. Run the scene and you'll see a character spawn and perform the actions that have been setup