Skip to main content
Version: 0.13.0

Your First Scene

The fastest way to understand the tool is to watch it run before you build anything. This page gets you there in about five minutes.

If you have not imported the asset yet, start with Requirements and Installation.

Open the Example Scenes window

From the Unity menu bar, choose:

BardTreeLtd/Civil AI/Examples/Create Example Scene

A window titled Example Scenes opens. It has two halves:

  • Open Existing Scene — every scene already sitting in the examples folder, with an Open button each.
  • A card per generated scene — a name, a description, the behaviour tree it uses, and a Create Scene button.

Press Play on the demo town

Under Open Existing Scene, find Example Scene and click Open. This is the hand-authored demo town that ships with the package: houses, workplaces, items, lighting and a baked NavMesh, all already set up.

Press Play.

You should see agents spawn, walk to workplaces, perform job actions, and head home when their needs demand it. A floating clock shows the world time advancing.

That is the whole system running. Everything else in this wiki is about authoring the content that drives it.

What to look for

While it is playing, these are the moving parts worth noticing:

  • Agents pick jobs and homes on spawn. A population region assigns each agent a workplace role and a house from the buildings in range.
  • Agents walk to a spot beside an item, not into it. That position is the item's use spot — see Use Spots.
  • Work and needs compete. An agent leaves its job when a need outweighs the current duty. Which need wins is decided by the need tree.
  • The clock drives everything. A fresh world opens at 08:00 by default.

Select an agent in the Hierarchy while playing. Its inspector shows the current behaviour, action and target, which is the quickest way to understand why an agent is doing what it is doing.

Try the feature scenes

The three cards in the wizard each generate a scene built around one feature:

SceneWhat it demonstratesBehaviour tree
Bespoke AgentsA hand-placed agent in every workplace position, each with a home, instead of a population region spawning them from the character poolDemo0.3.0
Route UsageA patrolling agent that follows a fixed route there and back over the workplace's waypointsPatroller
Slot SystemAn agent that picks up items of different sizes into matching inventory slotsSlot Example

Click Create Scene on any card, wait for the progress bar, and press Play. Create All Scenes generates all three at once.

warning

Create Scene replaces the scene of that name. If you have edited a generated scene and want to keep your changes, rename it or move it out of the examples folder first. The flip side is useful: if you break one experimenting, just regenerate it.

Why you do not need to configure anything first

This is the part that trips people up when building by hand.

Normally, which behaviour trees load is decided by the work and need repository fields in Module Settings — one global setting for the whole project. That means a scene built around a patrol route and a scene built around inventory slots cannot both be correct at once.

Generated example scenes get around this with an ExampleBehaviourRepositoryOverride component, sitting on an ExampleBootstrap object in the scene. It names the work and need repositories that scene wants, and applies them at Play before the modules initialise.

So each example scene self-selects its own trees, and you can move between them without touching Module Settings. You can use the same component in your own scenes — see Example Scenes.

Leaving either field blank falls back to the global Module Settings value.

If nothing happens

SymptomUsual cause
Agents spawn but never moveNo navigation data. Check Nav Mode in Module Settings and that a NavMeshSurface is baked.
Everything renders magentaWrong render pipeline materials — see Requirements and Installation.
No agents at allThe population region has no valid character pool, or no house and workplace with an open position in range.
Console errors on PlayMissing packages. AI Navigation and Input System are both required.

Common Issues covers more.

Next step

Now that you have seen a working scene, Getting Started walks through building one yourself.

If you would rather understand the concepts first, go to Introduction to CIVIL-AI-SYSTEM.