Resource collector (Crystal)
Steps how to create a resource collector.
Last updated
Steps how to create a resource collector.
Last updated
To create new resource collector unit we must again first create a AUnitSO
data set with capabilities, before we create a prefab.
Select Unit type of asset
Click Create New button
Set desired name and description of the new unit
Set cost to the unit like resource, wood, etc.
Set production attributes like Population Consumption if applicable for your project; it is used in Demo scene.
Set requirements research or other producible if applicable, like the new Crystal Age research.
Select Capabilities tab
Add Resource Collector capability to support unit collecting resources from resource nodes.
Add Health capability so that unit may be destroyed by enemy units.
(Optional) Add Builder capability to support building other constructions, this is relevant only if the collector is also a general worker for the player.
After data asset is created, we can proceed with creating a Unit prefab:
Click on the Create Prefab button if you wish for prefab to be created automatically.
Now click Open Prefab to and open Scene window to see it. You should see 3 components already present (Unit, Health, Resource Collector).
Configure visuals as desired, by default a primitive cube model is present.
Add collider to the root game object, primarily for selection and projectile collisions.
Set Layer of the root object (the one with collider) which is used for selection and projectile collision.
Add movement components. This is required if the unit is to support movement with provided tasks and behaviours (collection, combat, building, etc.).
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
)
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.
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 .