RegisterForDistanceLessThanEvent - ScriptObject

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ScriptObject

Registers this script to receive a single OnDistanceLessThan event when two objects are closer than the specified distance apart. If the objects are already that close, the event will be sent immediately.

Only the script that registers for an event will receive it. Other scripts attached to the same form, alias, or magic effect will not receive the event unless they also register for it.

Syntax[edit | edit source]

Function RegisterForDistanceLessThanEvent(ScriptObject akObj1, ScriptObject akObj2, float afDistance) native

Parameters[edit | edit source]

  • akObj1: The first object to check distance with. (Must be an ObjectReference or ReferenceAlias)
  • akObj2: The second object to check distance with. (Must be an ObjectReference or ReferenceAlias)
  • afDistance: How close the objects must be before the event is sent

Return Value[edit | edit source]

None

Examples[edit | edit source]

; Register for an event when the stalker is closer then 100 units from me
RegisterForDistanceLessThanEvent(Me, Stalker, 100.0)

Notes[edit | edit source]

  • The form that this function is called on doesn't have to be either object. In this way you could have a quest that gets distance events from between the player and a quest objective.
  • The two object parameters are interchangeable. If you re-register for a distance less than event using the same two objects in a different order, your current registration will simply be updated with the new distance.
  • A script can only be registered for one distance less than event per object pair. If you register for another one, the distance will be updated. You can, however, register for a distance greater than event between the same pair without affecting this registration.
  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.

See Also[edit | edit source]