← Previous | Next →
getClosestPlayer
Description
Finds the closest player to the NPC within a specified distance and stores the player entity in a global variable.
Name | Type | Possibilities |
getClosestPlayer | behaviour | 2 |
Parameters
# | Name | Type | Mandatory | Description | Multiple |
1 | player | Entity | Yes | The global variable name where the player entity will be stored. | No |
2 | distance | number | No | The maximum distance to search for a player. Defaults to 200 if not specified. | No |
Outputs
# | Description |
1 | The closest player was found and stored in the global variable. |
2 | No player was found within the specified distance. |
Example
NPC
name Watcher
model s_m_m_security_01
position -1020.72 4839.78 258.30 0.0
interaction
nothing
behaviour
getClosestPlayer closestPlayer 15