Difference between revisions of "OnTriggerEnter - ObjectReference"
OnTriggerEnter - ObjectReference (edit)
Revision as of 07:41, 9 October 2021
, 07:41, 9 October 2021→Notes
imported>Cipscis |
imported>Rasikko m (→Notes) |
||
(3 intermediate revisions by 2 users not shown) | |||
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 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> | |||
*If you set a trigger around a teleport door marker this event will fire for the player but not for NPCs. | |||
*The collision layer associated with a primitive containing the script for this event doesn't detect dead actors. | |||
== See Also == | == See Also == |