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 (Projectile Prefab)
  • Step 4 (Add to Production)
  1. Getting Started
  2. Create Units

Combat unit (Mage)

Steps how to create a combat unit, in our case a range unit (mage) which fires projectiles.

PreviousResource collector (Crystal)NextProduction unit (Mage Tower)

Last updated 1 month ago

Step 1 (Asset)

To create new combat 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 of production like the new crystal resource itself, or food, 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.

  7. Select Capabilities tab

    1. Add Health capability so that unit may be destroyed by enemy units.

    2. Add Attack capability to add support for attacking other entities in scene.

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 and Unit Attack).

  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. 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 IUnitMovement interface. Alternatively you subclass the AUnitMovement provided in the package, which has some basic implementation and configuration present.

  6. Set Layer of the root object (the one with collider) which is used for selection and projectile collision.

  7. If your combat unit is a ranged unit, you can attach ProjectileLauncher component which handles shooting projectiles for you. This is achieved by setting the UnitAttack component ManuallyTriggerAttack flag to true and add listener to the OnAttack event on the component.

    1. Set Projectile Prefab reference, you can use provided projectiles, or create your own by following the steps below.

Step 3 (Projectile Prefab)

In case you'd like to create your own projectile instead of using demo prefabs, here are few things you need to know.

To can create new projectile for mage, you can either use provided BasicProjectile script or create your own script and implement interface IProjectile on it.

IProjectile script must be attached to the root game object of the prefab.

  1. Create new game object and attach BasicProjectile script or duplicate existing projectile examples.

  2. Configure script to your project's requirements (followTarget, lifeDuration, etc), the most important on being:

    1. Type - which defines behaviour of projectile's movement or provide your own MovementObject reference to replace built-in movement

    2. Target Layer - defines collision layer for detecting when target unit has been hit

    3. Ignore Obstacles & Obstacle Layer - when ignoring obstacles is set to false make sure to also set the layer's used for obstacles

  3. Now back to Mage prefab and set the new projectile to the field ProjectilePrefab on the ProjectileLauncher script.

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
Create Mage unit 1/2
Create Mage unit 2/2
Create new projectile