RegisterForDistanceGreaterThanEvent - ScriptObject

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ScriptObject

Registers this script to receive a single OnDistanceGreaterThan event when two objects are farther then the specified distance apart. If the objects are already that far apart, 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 RegisterForDistanceGreaterThanEvent(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 far apart 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 father is farther than 1000 game units from the child or more
RegisterForDistanceGreaterThanEvent(Child, Father, 1000.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 greater 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 greater than event per object pair. If you register for another one, the distance will be updated. You can, however, register for a distance less 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]