> For the complete documentation index, see [llms.txt](https://travljen.gitbook.io/unit-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://travljen.gitbook.io/unit-system/getting-started/create-units/production-unit-mage-tower.md).

# Production unit (Mage Tower)

There are few ways to give the player access to the new resource.

* **Unit's Passive Resource Production** - Supports constant production of a resource.
* **Unit's Active Production** - Supports production of any producible object (resource, research, unit, etc.).
* **Resource Node** - Supports collectors to gather resource, either from node (entity) or structure (unit), like praying on temple structure for god's favour.
* Or you limit the player and only give him initial resource, no option to collect new.&#x20;

In previous tutorials we already covered the resource node and combat unit. Now we will create a **Mage Tower** that will produce **Crystals** passively and produce **Mages** actively.

## Step 1 (Asset)

To create **new production unit** we must again first create a `AUnitSO` data set with **capabilities**, before we create a prefab.

Open up the **UnitSystem window** and proceed with the steps:

1. Select **Unit** type

2. Click **Create New** button

3. Set desired **name** and **description** of the new unit

4. Set **cost** of the unit, resources player must consume to produce/place this unit

5. Set **requirements** research or other producible if applicable, like the new **Crystal Age** research.

6. Set **production attributes** like **Population Capacity** if this structure should increase housing of units. Additionally you can create new **Unit Limit attribute** which specify a **Mage unit**, this functionality limits player's max number of mages and each tower could increase the limit for X amount.

   <figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FPMa6n4V2oqVf1HNgzTcg%2FMage%20Tower%20Asset%20-%20Main.png?alt=media&amp;token=30f58675-d237-4563-ab60-ac13184ff8e0" alt="" width="563"><figcaption><p>Mage Tower Asset 1/2</p></figcaption></figure>

7. Select **Capabilities** tab

   1. Add **Health capability** so that unit may be destroyed by enemy units.
   2. Add **Buildable** capability which enables the unit to be constructed before it becomes operational.
   3. Add **Passive Resource Production** **capability** and set production resource with its quantity produced per second.
   4. Add **Active Production capability** for production of **Mage** units.
      1. Here you can add support for the unit to produce any producible you have available.

   <figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FrxubSdXym1rRgQsBSrUf%2Fimage.png?alt=media&amp;token=94bfa659-10d9-43b8-a15e-45d0b6e4949d" alt="" width="563"><figcaption><p>Mage Tower Asset 2/2</p></figcaption></figure>

## Step 2 (Prefab)

After data asset is created, we can proceed with creating a Unit prefab:

1. Click on the **Create Prefab** button if you wish for prefab to be created automatically.
2. Now click **Open Prefab** to and open **Scene** window to see it. You should see 5 components already present (**Unit**, **Health, UnitBuilding, UnitPassiveProduction** and **UnitProduction**).
3. **Configure visuals** as desired, by default a primitive cube model is present.
4. **Add collider** & **layer** to the **root game object**, primarily for selection and projectile collisions.

**Optional**

1. In case this unit will **produce and spawn other units** (like mage) then you should configure the default `UnitSpawnPoint` attached by default. This spawn point can be removed and replace with a custom `IUnitSpawn`.
2. **Manage object as obstacle on navigation path**.
   1. If you are using Unity's NavMesh system, you can add `NavMeshObstacle` component to define where navigation is not possible once building unit is placed.
      1. Additionally attach the `BuildingUnitNavMeshManager` component, this will toggle on/off obstacles and agents while unit is building respectively.
   2. If you are using a different navigation system, add it's obstacle component and create a new script to listen for events on `UnitBuilding` component where you can toggle your components on/off. See `BuildingUnitNavMeshManager` for example.
3. **Add building animation**:
   1. If you wish to use provided component add `RaiseBuildingAnimation`, set it's reference to the **animated transform** and **start offset** which will simply move the transform from offset back to `Vector3.zero` while building the unit.
   2. Or you can implement your own animations for building unit, by creating a component which derives from `ABuildingAnimation` class.
4. **For pre-defined interaction positions** use the `StaticInteractionPositionProvider` component.
   1. Select shape
   2. Define shape size
   3. Specify unit spacing
5. **Unit Selection - Integration**; If you are using Unit selection package for selecting units, check out the [Unit Selection](/unit-system/integration/unit-selection.md) page for more information.

<figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FnWjolFR3g7R0kiokgYRu%2Fimage.png?alt=media&amp;token=11d01f22-0674-45bd-90c2-f0b2026df720" alt=""><figcaption><p>Mage Tower Prefab Example</p></figcaption></figure>

## Step 3 (Add to faction)

If you are using an existing faction for testing this new unit, you can open it up or to create new faction with steps here [Faction (Purple Cubes)](/unit-system/getting-started/create-units/faction-purple-cubes.md).

Then add the unit to **default actions** of the faction. These actions will be presented in demo scene when any unit that has **Builder** capability is selected.&#x20;
