Difference between revisions of "OnTriggerEnter - ObjectReference"
Jump to navigation
Jump to search
OnTriggerEnter - ObjectReference (edit)
Revision as of 14:52, 29 November 2014
, 14:52, 29 November 2014→Notes: added example on keeping a count for the order of these events.
imported>Cipscis |
imported>Terra Nova2 (→Notes: added example on keeping a count for the order of these events.) |
||
Line 22: | Line 22: | ||
== Notes == | == Notes == | ||
This event can be received out of order with [[OnTriggerLeave - ObjectReference|OnTriggerLeave]], 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 [[OnTriggerLeave - ObjectReference|OnTriggerLeave]], 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 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 | |||
</source> | |||
== See Also == | == See Also == |