1. Home
  2. Unity RTS Engine
  3. Units
  4. General Unit Components

General Unit Components

The unit’s parent object has the following Unity components. This documentation page discusses the role of each one of this components.


Collider:

Collider component with “Is Trigger” set to true. This collider defines the unit’s boundaries in relation to obstacles in the map.


Rigidbody:

Rigidbody component with “Is Kinematic” set to true and “Use Gravity” set to false.


Audio Source:

  • Audio Source component with:
    • “Spatial Band” set to 3D (equal to 1).
    • Under “3D Sound Settings:
      • “Doppler Level” and “Spread” both set to 0.
      • “Volume Rolloff” set to “Linear Rolloff”.
      • “Min Distance” and “Max Distance” set to values that mirror how loud you want sound coming from the unit to be heard from distance.

Navigation Mesh Agent:

Nav Mesh Agent component which allows the unit to move on the navmesh.

Set the “Radius” field to the area that you want the unit to occupy on the navigation mesh.

Make sure that “Auto Braking” is set to true, especially when having a unit that moves with very high speed and that the area mask has the “Walkable” layer.


Animator:

If you want to animate your units while they are attacking, collecting resources, building, etc.. Then you need an Animator component attached to the main unit object (or the unit model but in this case you need to assign the animator in the main Unit component which will be covered in the next documentation page). The animator controller below can be found under RTS Engine\Units\Sources\Animations\Controllers. This controller is composed of 8 states: Idle, Moving, Collecting, Building, Attacking, Take Damage, Healing, Converting and Dead and 9 Boolean parameters (one for each state): IsIdle, IsMoving, IsCollecting, IsBuilding, IsAttacking, TookDamage, IsHealing, IsConverting and IsDead.

It’s advised that you create an Animator Override Controller for each unit and then have the above Unit Animator in the “controller” field of the animator override controller. This way you don’t have to re-create the animator controller for each unit but simply replace the empty animations with the ones you want to use for the unit you’re creating. Then you can simply attach the animator override controller in the “Default Animator Override Controller” field of the Unit component (also covered in the next documentation page).

How can we help?