Difference between revisions of "FindClosestReferenceOfTypeFromRef - Game"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Plplecuyer
 
imported>Tania
m (Look for the same type as the ref, and the ref is returned.)
Line 23: Line 23:
ObjectReference closestDiamond = Game.FindClosestReferenceOfTypeFromRef(Diamond, Game.GetPlayer(), 5.0)
ObjectReference closestDiamond = Game.FindClosestReferenceOfTypeFromRef(Diamond, Game.GetPlayer(), 5.0)
</source>
</source>
== Notes ==
*if arBaseObject is the same type as arCenter, this function will return arCenter instead. In other words
arCenter is not excluded from the the search.


== See Also ==
== See Also ==

Revision as of 08:49, 18 May 2017

Member of: Game Script

Finds the closest reference of the given type from the location of the target reference and within the given radius.

Syntax

ObjectReference Function FindClosestReferenceOfTypeFromRef(Form arBaseObject, ObjectReference arCenter, float afRadius) global

Parameters

  • arBaseObject: The type of base object to look for
  • arCenter: Reference to use as a center to search from
  • afRadius: Maximum distance from center to look for a reference

Return Value

The closest reference found, none if none.

Examples

; Find the closest diamond reference to the player, limiting the search to 5 units
ObjectReference closestDiamond = Game.FindClosestReferenceOfTypeFromRef(Diamond, Game.GetPlayer(), 5.0)

Notes

  • if arBaseObject is the same type as arCenter, this function will return arCenter instead. In other words

arCenter is not excluded from the the search.

See Also