Background for Fallout 4
Member of the ObjectReference script
floatfunctionGetDistance(ObjectReferenceakOther)Native

Description

Wiki Description

Calculates the distance between this object and the passed in one.

Documentation Comment

Calculates the distance between this reference and another - both must either be in the same interior, or same worldspace


Caveats

CK Wiki - Notes

  • If you are wanting to know when something is closer or farther then a specified distance from another one, you should instead use RegisterForDistanceLessThanEvent or RegisterForDistanceGreaterThanEvent instead of constantly checking the distance using this function manually which is less efficient.
  • Calling this function on an actor to check the distance of an objectreference will result in distance larger than expected. Where as calling said objectreference on an actor(even the same actor) will return a correct value. Source

Parameters

ObjectReferenceakOther

CK Wiki Description

The object to find the distance to.


Examples

; Find out how far away the player is from the chest (assuming they are in the same interior or worldspace)
Debug.Trace("Player is " + Game.GetPlayer().GetDistance(Chest) + " units away from the chest")

Auto-Generated Example

ObjectReference myObjectReference__akOther

float returnedValue = myObjectReference__toCallFunctionOn.GetDistance(myObjectReference__akOther)

Related Pages


Additional References

View this function’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.