---
description: Steps how to create a resource collector.
---

# Resource collector (Crystal)

## Step 1 (Asset)

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

1. Select **Unit** type of asset
2. Click **Create New** button
3. Set desired **name** and **description** of the new unit
4. Set **cost** to the unit like resource, wood, etc.
5. Set **production attributes** like **Population Consumption** if applicable for your project; it is used in Demo scene.
6. Set **requirements** research or other producible if applicable, like the new **Crystal Age** research.

<figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FPVNDEmy1b49sTG4etlOH%2Fimage.png?alt=media&#x26;token=8b9849eb-bf31-48a6-aa36-d18e7584258c" alt=""><figcaption><p>Crystal Collector Main 1/2</p></figcaption></figure>

7. Select **Capabilities** tab
   1. Add **Resource Collector capability** to support unit collecting resources from resource nodes.
   2. Add **Health capability** so that unit may be destroyed by enemy units.
   3. (Optional) Add **Builder capability** to support building other constructions, this is relevant only if the collector is also a general worker for the player.

<figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FZS1ZlmPe07P0O858zGHO%2FCrystal%20Collector%20Capabilities.png?alt=media&#x26;token=45fd01d1-bff1-403b-ac77-ca1462994a5f" alt=""><figcaption><p>Crystal Collector Capabilities 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 3 components already present (**Unit**, **Health, Resource Collector**).
3. **Configure visuals** as desired, by default a primitive cube model is present.
4. **Add collider** to the **root game object**, primarily for selection and projectile collisions.
5. **Set Layer** of the root object (the one with collider) which is used for selection and projectile collision.
6. Add **movement components**. This is required if the unit is to support movement with provided tasks and behaviours (collection, combat, building, etc.).
   1. If you are using Unity's NavMesh, you can attach `NavMeshAgent` for navigating the object and provided `NavMeshMovement` components. (If you are integrating it with Formation asset, use `FormationNavMeshMovement`)
   2. If you are using different navigation system or want to customise your movement component, create a new `MonoBehaviour` script and implement `UnitMovement` interface on it.

<figure><img src="https://3582497942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy2G6fDLEPuCAcuABMl6j%2Fuploads%2FJeIOZyrwuyyyxtMNiwAH%2FCrystal%20Collector%20Prefab.png?alt=media&#x26;token=717ddfec-f7d6-43d3-9aea-f09af205177f" alt=""><figcaption><p>Crystal Collector Prefab</p></figcaption></figure>

## Step 4 (Add to Production)

Now that you have a new production object ready, you must add it to any unit which supports Production itself. You can add this to any existing production structures present in Demo assets, or create your own following the guide for [Mage Tower](production-unit-mage-tower).
