Talk:OnTrigger - ObjectReference
Reverse engineering[edit source]
The code that dispatches this event works in terms of what refs are in the trigger at a given moment. Specifically, if the trigger is an hkpSimpleShapePhantom, then the code creates an hkpAllCdBodyPairTempCollector, uses that to find all physics objects in the trigger (by way of hkpShapePhantom::GetPenetrations, called without an hkpCollisionInput), and for each found object, it calls a function (Address Library ID 26038 for AE) to attempt to dispatch the event. If instead the trigger is an hkAabbPhantom, then the game loops over its overlappingCollidables, calling ID 2038 on each one. Either way, after looping over all objects currently in the trigger, if any event was dispatched, then the trigger's last-dispatch timestamp is updated.
(Notably, ID 26038 checks the timer, i.e. they're repeatedly re-checking a timer that has not changed, instead of gating the entire for-each-object loop behind the timer.)
So the trigger fires events in batches -- one event for every ref (with the appropriate collision layer(s)) currently in the trigger -- and batches are, at minimum, fTriggerEventDelayMS milliseconds apart. Individual events within a batch are not spaced apart.
DavidJCobb (talk) 22:17, 9 July 2026 (EDT)
- The game's bhkWorld invokes a member function of TriggerEntry, Address Library ID 26036 for AE, seemingly on every tick. This function handles dispatching OnTrigger, OnTriggerEnter, and OnTriggerLeave.
- The function exits without doing anything if the trigger ref is disabled, deleted, or doesn't have 3D loaded.
- The function acts on a list of TriggerEntry::TriggerEvents. The list is already populated by the time this function runs; I don't know where it gets populated from...
- DavidJCobb (talk) 22:41, 9 July 2026 (EDT)