Unit Manager

Author: zelixsphere 253 views

Unit Manager, what is it?

The Unit Manager, in the simplest of terms, is a software component of the RTS Module, that allows you, the game developer, to control your game Units. 

For all intents and purposes Unit Manager is very much the same as “Player”. The more Unit managers, then the more Players. A good example of this in practice, 2 Unit Managers in the same scene, one for the AI, and one for You, each with their own units. 

Given the fact that Unit Manager controls your specific Units we need to first address and identify how the Unit Manager would do this. There are 3 unique ways.

  • Scene Units Only
    • In Scene Units prior to ‘Run Time’
  • Prefab Units Only
    • Prefab Units during ‘Run Time’
  • Combination of Scene or Prefab Units
Please see below for a more detailed description of Unit Manager components

Components of a Unit Manager- with color key for above image

  • Thick Green = Unit Manager Component / File
    • Should be placed on its own Empty Game Object then named as you see fit
    • Can have more than one instance of Unit Manager, but on separate, Empty Game Objects
  • Blue The UI Elements associated with the Unit Manager
    • Light Blue
      • Selection Box Rectangle
        • By default needs to be inactive
          • This is simply just a blank UI Image
        • Reflects when we ‘drag‘ across screen to select Units
      • Layer Mask
        • Should be set to “Unit“, as you would normally want to only select Game Objects (Units), that you control
    • Dark Blue
      • Selection Marker (Prefab)
        • This allows the player during runtime, to see where the click anywhere in the scene
      • Layer Mask
        • Should be set to “Everything“, as you would normally want to see this anywhere you click
  • Orange = Scene Units
    • In Most Scenarios you would not use touch this
      • Most cases you would assign all player and enemy units as prefabs in the Game Manager which then auto populate here.
      • Please visit Game Manager for how to set this up
    • Alternative Scenarios if not using Game Manager
      • These are Units already in the Scene prior to starting the Game
      • In Scene Units prior to ‘Run Time’
      • These are Units you would drag from Scene to Units List in Unit Manager
  • Purple = Prefab Units
    • Most Scenarios you would not touch this
      • Most cases you would assign all player and enemy units as prefabs in the Game Manager to be discussed in upcoming tutorial versus here
    • Alternative Scenarios if not using Game Manager
      • These are Units you setup as prefabs saved in a folder in your project but that are not in the scene until you run the Game
        • Prefab Units during ‘Run Time’ that are instantiated
      • These are Units you would drag from Prefab Folder to Unit Prefab List in Unit Manager, to be instantiated.
  • RedPlayer Spawn Point
    • This would be a Game Object, where you would like your units to be instantiated from.
    • Keep in mind, this is a temporary solution for instantiation position of player(s).
      • There will be a more robust option , that gives you the ability to assign spawn point per Unit coming soon.
    • Example use case could be the home base building being the central spawn point of all troops
      • Each Unit Manager has their own spawn points, so enemy spawn point would be different than the players

Important to note that the check box should only be selected for the Unit Manager that belongs to the Player. Enemy Unit Managers would not have this check box checked.

In most cases Units would be setup in the Game Manager versus Unit Manager, unless you are setting up something beyond a normal RTS. I wanted to allow for more solutions, which is why these options are here.

On this page