Resource Containers

A resource container represents a place where a particular kind of resource can be stored, added or removed. Examples are ammo, energy, heat, etc.

Creating A Resource Container

To create a resource container:

  1. Add a Resource Container component to a game object

  2. Open the inspector and customize the settings, using the tooltips to understand what they mean

The Resource Container component has many functions you can call to get information about or modify its state. Here are a couple of key things to know.

Adding/Removing Resources

To add or remove resources from a resource container, call the resource container's Add Remove function. Passing a negative value as the parameter is a removal, and a positive value is an addition.

// Remove 1 resource from container
myResourceContainer.AddRemove(-1);

// Add 1 resource to container
myResourceContainer.AddRemove(1);

Continuous Replenishing/Depletion

If you have an energy resource container for weapons, you may want it to slowly replenish over time. Or if you have a heat resource container, you may want it to slowly deplete over time as heat is dissipated.

To set this up, customize the Change Rate value in the inspector of the Resource Container component. A positive value represents replenishing and a negative value represents depletion, and the value is the amount per second.

Emptying/Reloading

To create fun, balanced game mechanics, you can set the resource container to completely refill a specified time after becoming emptied (e.g. bullets are depleted, wait, bullets are reloaded). To do this, check the Fill To Capacity After Emptied Pause checkbox in the inspector of the Resource Container component.

You can also set the resource container to completely empty a specified time after becoming completely full (e.g. heat production and dissipation). To do this, check the Empty After Filled Pause checkbox in the inspector of the Resource Container component.

Resource Types

A resource type (Resource Type component) represents a particular kind of resource, such as ammo, heat, or energy.

To create a new resource type:

  1. Right click in the Project tab and select Create > Universal Vehicle Combat > Resource Type and rename it to whatever you wish.

  2. Open the inspector of any Resource Container component and set the resource type there.

Last updated