Unit System
  • WELCOME
    • πŸ‘‹Hello
    • πŸ—ΊοΈRoadmap
    • ⛑️Support & Community
    • πŸŽ“Version - Changelog
  • Getting Started
    • πŸ”ŒImport Package
    • βš™οΈConfiguration
    • πŸ” Database
    • πŸͺŸManager Window
    • Creating a new Scene
      • Player Camera
      • Set up Player
      • Set up Player UI
      • Set up the Game World
    • Create Units
      • Resource (Crystal)
      • Research (Crystal age)
      • Resource node (Crystal Node)
      • Resource collector (Crystal)
      • Combat unit (Mage)
      • Production unit (Mage Tower)
      • Faction (Purple Cubes)
  • How it works
    • Overview
    • Modules
      • Resource
      • Production
      • Population
      • Garrison
      • Collection
  • Integration
    • Unit Selection
    • Unit Formation
    • Object Placement
Powered by GitBook
On this page
  • Step 1 (Asset)
  • Step 2 (Prefab)
  • Step 3 (Add to faction)
  1. Getting Started
  2. Create Units

Production unit (Mage Tower)

PreviousCombat unit (Mage)NextFaction (Purple Cubes)

Last updated 15 days ago

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.

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.

  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.

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 page for more information.

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).

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.

Mage Tower Asset 1/2
Mage Tower Asset 2/2
Mage Tower Prefab Example