Background for Skyrim SE
Member of the ObjectReference script

Description

Wiki Description

Event called when the object reference is a trigger volume and has been left.

Documentation Comment

Event received when this trigger volume is left


Caveats

CK Wiki - Notes

  • This event can be received out of order with ObjectReference.OnTriggerEnter(...), so it's ideal to keep a count instead of a simple true/false value for when things are inside the trigger.
Int InTrigger = 0

Event OnTriggerEnter(ObjectReference akTriggerRef)
    if (InTrigger == 0)
        if akTriggerRef == Game.GetPlayer()
            InTrigger += 1
            debug.notification("Entered Trigger")
        endif
    endif
EndEvent

Event OnTriggerLeave(ObjectReference akTriggerRef)
    if (InTrigger > 0)
        if akTriggerRef == Game.GetPlayer()
            InTrigger -= 1
            debug.notification("Leaving Trigger")
        endif
    endif
EndEvent
  • If an ObjectReference's 3D unloads, that counts as the ObjectReference "leaving" the trigger.
  • If the trigger's own 3D unloads, that also counts as all ObjectReferences inside the trigger "leaving" the trigger.
  • If the player leaves the current loaded area, that unloads 3D for all ObjectReferences in the space they're departing, potentially firing OnTriggerLeave. The OnCellDetach event is not likely to run to completion before the refs begin to unload their 3D en masse, so you can't e.g. disable the trigger on detach to avoid being hit with unwanted OnTriggerLeave events.

Parameters

  1. ObjectReferenceakActionRef

    CK Wiki Description

    The ObjectReference that left the volume.


Examples

Event OnTriggerLeave(ObjectReference akActionRef)
  Debug.Trace(akActionRef + " just left us!")
EndEvent

Auto-Generated Example

Scriptname MyCoolScript extends ObjectReference

event OnTriggerLeave(ObjectReference akActionRef)
    Debug.trace("Event received - OnTriggerLeave: akActionRef = " + akActionRef)
endEvent

Related Pages


Additional References

View this event’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.