Unity RTS Engine

  1. Home
  2. Unity RTS Engine
  3. Resources
  4. Resource Main Component

Resource Main Component

The resource’s parent object has the Resource component attached to it. This is the main component that defines a resource. The resource’s parent object must have its layer set to “Resource” as well.


Resource General Settings:

  1. Name: Input the resource type in this field, this is the same name that is defined in the Resource Manager component.
  2. Code: Unique for each resource variation (for example, two resources can have different models and look but they allow the unit to collect the same resource type, therefore they must have the same Name but different codes).
  3. Radius: The radius of the resource on the navigation mesh.
  4. Amount: The amount that this resource hold.
  5. Infinite: When enabled, the resource’s amount will be infinite.
  6. Destroy On Complete: In case the resource amount is not infinite and this is set to true, then the resource object will be destroyed when its amount is null.

Collection & Drop Off Settings:

  1. Collect Outside Border: When enabled, then units will be able to collect this resource even if it’s outside their faction resources.
  2. Collect Amount Per Second: The amount that a unit collects from this resource each second.
  3. Have Drop Off Range: When enabled, then this will require the collector to drop this resource only to drop off buildings that are inside a certain range. You should only consider this option if the resource collection mode is not set to automatic.
  4. Drop Off Range: the range size for the above option.

UI Settings:

  1. Show Collectors: When enabled, the amount of collectors will be shown in the selection panel when the resource is selected.
  2. Show Amount: When enabled, the amount of the resource will be shown in the selection panel when the resource is selected.

Resource Components:

  1. Resource Plane: This is the object that holds the selection texture and which will be activated when the resource is selected. Also a child object of the main resource’s object and has “Resource” as its layer.
  2. Player Selection: The selection collider must not be the same as the resource’s main collider. Therefore, create a new empty object and make it child of the main resource’s object. The selection collider must not be the same as the resource’s frontier collider. It’s a child object of the resource parent object. It includes a Collider component with “Is Trigger” set to true. This collider represents where the player has to click with the mouse in order to select the resource and also acts as hitbox for attack objects. It also has the Selection Obj component attached to it. The selection object is then assigned to the “Resource Selection Component” field in the Resource component, the Selection Obj component has the following fields
    1. Obj Type: Set to Resource.
    2. Can Select: Can this resource be selected?
    3. Select Owner Only: Only applicable for units & buildings.
    4. Minimap Icon Size: Represents the size of the minimap icon for this resource.

 

How can we help?