Editing
IsNearPlayer - ObjectReference
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[Category:Scripting]] [[Category:Papyrus]] '''Member of:''' [[ObjectReference Script]] 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. == Syntax == <syntaxhighlight lang="papyrus"> bool Function IsNearPlayer() Actor player = Game.GetPlayer() Cell targetCell = self.GetParentCell() Cell playerCell = player.GetParentCell() if (targetCell != playerCell) if (targetCell && targetCell.IsInterior() || playerCell && playerCell.IsInterior()) return false else if (player.GetDistance(self) > 3000) return false else return true endif endif else return true endif endFunction </syntaxhighlight> == Parameters == None. == Return Value == Returns TRUE if the player is NOT in the same cell as the reference object and the player is also more than 3000 units away from the reference object. Alternatively returns TRUE if the Player is in an interior cell and the reference object is not (or vice-versa), even if the distance would otherwise be less than 3000 units. If neither of the above conditions are met, returns FALSE. == 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 [[IsDetectedBy - Actor]] or [[Is3DLoaded - ObjectReference]]. == Examples == <syntaxhighlight lang="papyrus"> ; Disable the box, but only if the player isn't nearby if (!Box.IsNearPlayer()) Box.Disable() endif </syntaxhighlight> == See Also == *[[ObjectReference Script]]
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values