OnTriggerLeave - ObjectReference

From the CreationKit Wiki
Revision as of 14:53, 29 November 2014 by imported>Terra Nova2 (→‎Notes)
Jump to navigation Jump to search

Member of: ObjectReference Script (Papyrus)

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

Syntax

Event OnTriggerLeave(ObjectReference akActionRef)

Parameters

Examples

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

Notes

  • This event can be received out of order with 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 akTrifferRef)
	if (InTrigger == 0)
		if akTrifferRef == 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

See Also