#How do you get the closest to the farthest players from a player
1 messages · Page 1 of 1 (latest)
U could use an Overlap Sphere with a radius of the distance of the farthest player from the local player (Get Farthest, Get All Players, Get Local Player), which sorts all the players by closest distance to farthest. U could also use a For Each and loop through all the players while keeping track of their distance from the local player, then insert each player and their distance into a List <Player> variable and a List<Float> variable, respectively, depending on that distance in comparison to the other distances in the list.
The easiest method is probably what @muted sun first suggeseted
Overlap Spherewith a radius of infinity which only detects players
For EachtheList<Collision Data>Result
On theFor Each"Loop" execution, add theCollision Data Get Playerof the loop item to aList<Player>Variable
The resulting variable will be a list of players sorted closest to furthest from the origin
*Note that you will need to clear the player variable before the For Each every time you want to re-do this to avoid the variable duplicating players
get farthest from all players, get closest from all players without the fartest player in it, have farthest as origin
if that wasnt a typo & actually need a sorted list, just when u get closest to farthest player, add that player to new list, remove player from the get closest list, & repeat until list for get closest is 0
personally id actually just prefer this. You know your farthest will be at index 0, so remove from sorted at index 0 when int switch reaches 0 if u need
ah, just read the others, overlap sphere not a bad idea but i hate collision data & forgor they fixed how it sorts by closestest now