Difference between revisions of "OnTriggerLeave - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Jlundin
 
imported>Terra Nova2
m (→‎Notes: typos)
 
(3 intermediate revisions by 3 users not shown)
Line 22: Line 22:


== Notes ==
== Notes ==
This event can be received out of order with [[OnTriggerEnter - ObjectReference|OnTriggerEnter]], so it's ideal to keep a count instead of a simple true/false value for when things are inside the trigger.
*This event can be received out of order with [[OnTriggerEnter - ObjectReference|OnTriggerEnter]], so it's ideal to keep a count instead of a simple true/false value for when things are inside the trigger.
 
<source lang="papyrus">
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
</source>


== See Also ==
== See Also ==

Latest revision as of 17:25, 2 December 2014

Member of: ObjectReference Script (Papyrus)

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

Syntax[edit | edit source]

Event OnTriggerLeave(ObjectReference akActionRef)

Parameters[edit | edit source]

Examples[edit | edit source]

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

Notes[edit | edit source]

  • 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 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

See Also[edit | edit source]