Background for Fallout 4
Member of the ScriptObject script
eventOnDistanceGreaterThan(ObjectReferenceakObj1, ObjectReferenceakObj2, floatafDistance)

Description

Wiki Description

Event called when two objects are farther then the registered distance apart - if this script is registered for it.

This event will only be sent to the specific script that registered for it. Other scripts attached to the same form/alias/active magic effect will not receive the event unless they also register.

Documentation Comment

Distance event - sent when the two objects are greater then the registered distance apart.
Obj1 and Obj2 are interchangable.


Caveats

CK Wiki - Notes

  • The two objects are interchangeable. They always match the order they were registered in, assuming someone else didn't register with the opposite order first.
  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.

Parameters

  1. ObjectReferenceakObj1

    CK Wiki Description

    The first ObjectReference which the distance check was performed on.

  2. ObjectReferenceakObj2

    CK Wiki Description

    The second ObjectReference which the distance check was performed on.

  3. floatafDistance

    CK Wiki Description

    The exact distance between the two objects at the time the event fired.


Examples

Function SomeFunction()
  RegisterForDistanceGreaterThanEvent(Game.GetPlayer(), Bird, 1000.0) ; Before we can use OnDistanceGreaterThan we must register.
EndFunction

Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
    ;/ If other registrations had been done, we would want to check the objects
       But since we only registered for one we know what it is /;
    Debug.Trace("Player is now " + afDistance + " units away from the bird - let's land")
endEvent

Auto-Generated Example

Scriptname MyCoolScript extends ScriptObject

event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
    Debug.trace("Event received - OnDistanceGreaterThan: akObj1 = " + akObj1 + " akObj2 = " + akObj2 + " afDistance = " + afDistance)
endEvent

Related Pages


Additional References

View this event’s page on the Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.