Getting Started - IsaacMulcahy/RPG-AI-SYSTEM-WIKI GitHub Wiki
here. This will be kept for a while and will eventually be removed.
This wiki has now moved toHow to get into the Project
- Bring up the 'Package Manager' in Unity (Window -> Package Manager - Found along the top left top bar in Unity)
- Search for CIVIL-AI-SYSTEM and select it from the list
- 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.
- Open the Example Scene
- Open the 'AI Manager' (Window -> AI -> CIVIL-AI-SYSTEM -> Overview Manager) - This can be skipped on V0.8.0 and above
- Save the scene - This can be skipped on V0.8.0 and above
- All good to go!
- Let us know how you find it and give us a Review on the Unity Asset Store
On Version 0.8.2 and above?
CIVIL-AI-SYSTEM now comes with a dynamic Getting Started guide (CIVIL-AI-SYSTEM -> HELP -> GETTING STARTED) which gives real time info dependent on context.
- If you are starting a new scene it provides a checklist of minimum setup.
- Creating your own behavior trees? It will provide important information on key subjects and suggestions
- Looking at example scene? Suggestions on what to try around with first
How to setup
Setup of the system is straight forward, using the Info and Actions.
-
Add in the module service (click any object within the scene and within the inspector click 'Add Component' -> Add the 'Module Service' ) - On V0.8.0 and above
-
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.
-
Add in your NPC character Game Object and click 'Setup object as NPC' and save this as a prefab and remove from scene.
-
Add the NPC prefab to the Character Pool (Module Settings -> Select the service 'Character Pool Service' (Check inspector) -> Select the 'Element 0 Scriptable object' -> Place within the character pool)
-
Add in your houses and workplaces (Both need colliders and within the region, can be triggers for the region to find them)
5.1. These are both made similarly to the NPC, that being within the Info and Actions has a template you can apply to any gameObject to setup them up. 5.2. Select the building and set the type and apply
5.3. Move the entrance center to be level with the Nav Mesh
5.4. Add a collision of some sort to allow the region to find the House/Workplace
-
Add jobs to the workplaces,
-
Increase the Resident max within the House to at least 1
-
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
- Set objects which the AI should be able to walk on as 'static' (top right box in the 'Inspector')
- Bring up the Nav Mesh window (Window -> AI -> Navigation)
- Select the 'Bake' tab
- Press 'Bake' (This can take some time)
- 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.
- Bring up the 'Behavior Tree Editor' (Found Window -> AI -> CIVIL-AI-SYSTEM -> Behavior Tree Editor)
- Within this screen it allows us to design the behavior of our NPC's
- Right click on the window space and select 'Job', this will create a Job Node which has a number of characteristics
- Change the 'Name'of the Job Node to 'Woodcutter'
- Then create a second node but this time Duty called 'Collect Wood'
- Connect these nodes by click and dragging from the 'Exit' to the 'Entry' section of the nodes
- Create a Task called 'Gather from Tree' and link to the Duty 'Collect Wood'
- Now we can create a Method and we will call it 'Find Tree to fall'
- 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
- Create another action but this time create it with the action characteristic being 'IDLE' and the 'Set Item in Use' ticked
- Now we need to add in a wait time and an animation for the felling of the Tree, this can be added using the endpoint behavior on the 'Idle' 'Action' node, we want to add an animation (the three columns represent 'start', 'middle' and 'end', we want the middle for our animation) in and give a wait time so we will update these fields
- Now that this is all done Save the AI Flow and call it 'Woodcutter'
- Go back to the Settings and change the 'Import Job System Data' selection to 'Woodcutter'
- Run the scene and you'll see a character spawn and perform the actions that have been setup