Background for Skyrim SE
Member of the ObjectReference script
boolfunctionIsNearPlayer()

Description

Wiki Description

A function that checks to see if this reference is either in the same cell or within 3000 units of the player. Commonly used in situations where the developer wants to be confident that an object can be enabled/disabled/moved/etc without the player being able to witness the action happening.

Documentation Comment

Function to know if I'm near the player (whether I can be safely enabled or disabled)


Caveats

CK Wiki - Notes

This function is useful for getting a general idea of if an object, NPC, or other entity is potentially visible or otherwise likely to be loaded by the game. For more specific instances of visibility, it would be better to use something like Actor.IsDetectedBy(...) or ObjectReference.Is3DLoaded().


Examples

; Disable the box, but only if the player isn't nearby
if (!Box.IsNearPlayer())
  Box.Disable()
endif

Auto-Generated Example

bool returnedValue = myObjectReference__toCallFunctionOn.IsNearPlayer()

Related Pages


Additional References

View this function’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.