First thing to add is a Collider component to the main unit object with “Is Trigger” set to true. This collider defines the unit’s boundaries in relation to some obstacles.
Add a Rigidbody component to the main unit object and Set “Is Kinematic” to true and “Use Gravity” to false.
Add an Audio Source component to the main unit object and make sure that:
- “Spatial Band” is set to 3D (equal to 1).
- Under “3D Sound Settings”, set “Doppler Level” and “Spread” both to 0. “Volume Rolloff” should be set to “Linear Rolloff”. And set the “Min Distance” and “Max Distance” to show how loud you want sound coming from the unit to be heard from distance.
Navigation Mesh Agent:
Add a Nav Mesh Agent component to the main unit object and pick the unit’s radius. This defines the space that the unit occupies on the navmesh.
Make sure that “Auto Braking” is set to true, especially when having a unit that moves with very high speed.
If the unit is a flying unit, then make sure to add the flyable navmesh mask in the area mask of the Nav Mesh Agent component (do not remove the walkable area from the area mask).
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).