Resource Container Triggers

Sometimes, you want to trigger an event a specified time after a certain threshold is crossed, and cancel the event if the value returns to the other side of the threshold.

A prime example is blowing up a vehicle if the heat reaches a certain level and stays above that level for a certain amount of time.

Creating A Threshold Trigger

To set up a Resource Container threshold trigger:

  1. Add a Resource Container Threshold Trigger component somewhere on the vehicle or module

  2. Set the Container in the inspector

  3. Add functions from any script (such as a Detonator component) to the On Threshold Crossed event in the inspector

  4. To cancel something when the resource container's value goes back under the threshold, add functions to the On Threshold Returned event in the inspector.

Threshold UI Bar

You may also want to display on a fill bar the amount of the threshold reached (rather than the amount of resource container filled).

To set this up:

  1. Create a UI Image and set the Image Type to Filled (you must set the sprite first, use the Square_Bounds sprite provided).

  2. Drag the image into the Threshold Fill Bar field in the inspector of the Resource Container Threshold Trigger component

Last updated