Difference between revisions of "OnTriggerEnter - ObjectReference"
Jump to navigation
Jump to search
imported>Heecf |
imported>Rasikko m (→Notes) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Scripting]] | |||
[[Category:Papyrus]] | |||
[[Category:Events]] | |||
'''Member of:''' [[ObjectReference Script (Papyrus)]] | |||
Event called when the object reference is a trigger volume and has been entered. | |||
== Syntax == | |||
<source lang="papyrus"> | |||
Event OnTriggerEnter(ObjectReference akActionRef) | |||
</source> | |||
== Parameters == | |||
*akActionRef: The [[ObjectReference Script (Papyrus)|ObjectReference]] that entered the volume. | |||
== Examples == | |||
<source lang="papyrus"> | |||
Event OnTriggerEnter(ObjectReference akActionRef) | |||
Debug.Trace(akActionRef + " just entered us!") | |||
EndEvent | |||
</source> | |||
== 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. | |||
<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 == | |||
*[[ObjectReference Script]] | |||
*[[OnTrigger - ObjectReference]] | |||
*[[OnTriggerLeave - ObjectReference]] | |||
*[[GetTriggerObjectCount - ObjectReference]] | |||
Latest revision as of 06:41, 9 October 2021
Member of: ObjectReference Script (Papyrus)
Event called when the object reference is a trigger volume and has been entered.
Syntax[edit | edit source]
Event OnTriggerEnter(ObjectReference akActionRef)
Parameters[edit | edit source]
- akActionRef: The ObjectReference that entered the volume.
Examples[edit | edit source]
Event OnTriggerEnter(ObjectReference akActionRef)
Debug.Trace(akActionRef + " just entered us!")
EndEvent
Notes[edit | edit source]
- This event can be received out of order with OnTriggerLeave, 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
- 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.