Background for Starfield
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.
    • Note, however, that because of the way Papyrus event handling and threading works, at any given moment, your count may be inaccurate, and there is a risk of the count becoming 'stuck' over time if events are not processed correctly. If your script requires precise accuracy, use the trigger's Interaction Conditions to restrict it to just the references you care about (eg. the player), then use ObjectReference.GetTriggerObjectCount() to verify that the reference is actually in the trigger at the time it matters.

Parameters

  1. ObjectReferenceakActionRef

    CK Wiki Description

    The ObjectReference that left the volume.


Examples

Event OnTriggerLeave(ObjectReference akActionRef)
  Debug.Trace(akActionRef + " just left us!")
EndEvent
; Check how many objects are inside the trigger so that the events run in proper sequence.
Event OnTriggerEnter(ObjectReference akTriggerRef)
    if GetTriggerObjectCount() == 1
        if akTriggerRef == Game.GetPlayer()
        ;    debug.notification("Entered Trigger")
            GetLinkedRef().Activate(Game.GetPlayer())
        endif
    endif
EndEvent

Event OnTriggerLeave(ObjectReference akTriggerRef)
    if GetTriggerObjectCount() == 0
        if akTriggerRef == Game.GetPlayer()
        ;    debug.notification("Leaving Trigger")
            GetLinkedRef().Activate(Game.GetPlayer())
        endif
    endif
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 Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.