Trigger Event Handler

→ Trigger Event Handler API

The Trigger Event Handler is a convenience component to act on trigger events without programmer. It is a specific implementation of an Event Handler.

It differs from the Collision Event Handler in that it uses trigger events and can also change Controller Input.

The Event

The Trigger Event Handler can be placed on GameObjects to catch trigger events and execute functions when this happens.

The Event Type works as follows:

  • Never: The event handler is disabled, the function is never called
  • On Start: The Target Method is called when the trigger collider is entered by a collider. This is equivalent to the OnTriggerEnter() message of Unity.
  • On End: The Target Method is called when the trigger is exited by a collider. This is equivalent to the OnTriggerExit() message of Unity.
  • While Active: The Target Method is called while a collider is touching the trigger collider. In that case it will be called in every frame. This is equivalent to the OnTriggerStay() message of Unity.
  • While Inactive: The Target Method is called while no collider is in the trigger collider. In that case it will be called in every frame.
  • On Change: The Target Method is called when a collider enters or exits the trigger collider.
  • Continuous: The Target Method will always be called in every frame, independent from the trigger events.

Target Method Parameters

GameObject

When the Target Method takes a GameObject as parameter, the Target Method will receive the GameObject of the collider which is touching the trigger collider.

Boolean

When the Target Method takes a boolean parameter, a Constant value can be used or the parameter can be set to From Event.

When the parameter is from the event, the boolean is true when the collider is touching the trigger collider and false when not.

Integer

When the Target Method takes an integer (Int32) parameter, a Constant value can be used or the parameter can be set to From Event.

When the parameter is from the event, the integer is 1 when the collider is touching the trigger collider and 0 when not.

Float

When the Target Method takes a float (Single) parameter, a Constant value can be used or the parameter can be set to From Event.

When the parameter is from the event, the float value is 1.0 when the collider is touching the trigger collider and 0.0 when not.

Controller Input

If the GameObject entering the trigger collider has Controller Input you can override the Controller Input while the GameObject is in the trigger collider. This enables you to assign a button to open a door when the player is close to that door for example.

The configuration is similar to the normal Controller Input. The difference is that empty entries do not override the Controller Input configuration. In the example above only the left Button 1 will be overridden, all other input will not be changed.

When the GameObject leaves the trigger collider, the Controller Input is restored to the original configuration.