Collision Event Handler

→ Collision Event Handler API

The Collision Event Handler is a convenience component to act on collision events without programming. It is a specific implementation of an Event Handler.

The Event

The Collision Event Handler can be placed on GameObjects and Rigidbodies to catch collision 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 collision starts. This is equivalent to the OnCollisionEnter() message of Unity.
  • On End: The Target Method is called when the collision ends. This is equivalent to the OnCollisionExit() message of Unity.
  • While Active: The Target Method is called while the collider is colliding with another collider. In that case it will be called in every frame. This is equivalent to the OnCollisionStay() message of Unity.
  • While Inactive: The Target Method is called while the collider is not colliding. In that case it will be called in every frame.
  • On Change: The Target Method is called when the collision starts or ends.
  • Continuous: The Target Method will always be called in every frame, independent from the collision 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 this 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 comes from the event, the boolean value is true when the collider is touching another collider and false when not.

Integer

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

When the parameter comes from the event, the integer value is 1 when the collider is touching another 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 parameters comes from the event, the float value is 1.0 when the collider is touching another collider and 0.0 when not.