-
Notifications
You must be signed in to change notification settings - Fork 94
get_player_distance
Ryzom Core Wiki edited this page Mar 13, 2023
·
3 revisions
title: Get Player Distance description: published: true date: 2023-03-12T23:27:57.218Z tags: editor: markdown dateCreated: 2023-03-12T23:27:54.313Z
The getPlayerDistance native AI script function calculates the distance between a player and a bot in meters.
(distance: f)getPlayerDistance(PlayerEidAsString: s, BotIndex: f) // getPlayerDistance_fs_f
- PlayerEidAsString (string): The EntityId of the player, passed as a string.
- BotIndex (float): The index of the bot, where 0 refers to the first bot in the current group.
This function returns the distance between the player and the bot in meters, or -1 if there was an error.
($playerEid)getCurrentPlayerEid(); (index)getBotIndexByName("toto"); (distance)getPlayerDistance($playerEid, index);
This example code gets the EntityId of the current player, gets the index of the bot named "toto", and calculates the distance between the player and the bot.