OnTriggerExit Event

Definition

function OnTriggerExit(otherActorName)

end

Description

This event is specific to the trigger object. Suppose a script that has an OnTriggerExit(otherActorName) event is attached to a trigger object. In this case, the OnTriggerExit(otherActorName) event is called once when the main character or a prefab instance that has dynamic physics exits the trigger.

Parameter

otherActorName
This parameter is automatically sent to OnTriggerExit event by Vanda engine. If a prefab instance that has dynamic physics exits the trigger, the name of its physics actor is sent to the OnTriggerExit event. If the main character of the game exits the trigger, the value nil is sent to the OnTriggerExit event.

Example 1

function OnTriggerExit(otherActorName)
    PrintConsole("\nOnTriggerExit() Event was called")
end
Assume that this script is attached to a trigger called “trigger1”. In this case, if the main character or a prefab instance that has dynamic physics exits “trigger1”, the message “OnTriggerExit() Event was called” will be displayed.

Example 2

function OnTriggerExit(otherActorName)
    if otherActorName == nil then
          PrintConsole("\nMain character is out of the trigger and OnTriggerExit() Event was called")
    else
          prefab_instance_name = GetPrefabInstanceNameFromActor(otherActorName)

          message = string.format("\nOnTriggerExit() Event was called. Prefab instance name is : %s" ,prefab_instance_name)
          PrintConsole(message)
    end
end
Assume that this script is attached to a trigger named “trigger1”. In this case, if the main character exits “trigger1”, the message “Main character is out of the trigger and OnTriggerExit() Event was called” will be displayed. Otherwise, if a prefab instance that has dynamic physics exits this trigger, the name of its physics actor is sent to the OnTriggerExit event. Using the GetPrefabInstanceNameFromActor function, we find the prefab instance name that otherActorName name belongs to and display it in the console.
adminOnTriggerExit Event