#How do you get the closest to the farthest players from a player

1 messages · Page 1 of 1 (latest)

unique kite
#

.

carmine imp
#

Get closest

#

Get farthest

#

Two chips

muted sun
# unique kite .

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.

carmine fiber
# unique kite .

The easiest method is probably what @muted sun first suggeseted

Overlap Sphere with a radius of infinity which only detects players
For Each the List<Collision Data> Result
On the For Each "Loop" execution, add the Collision Data Get Player of the loop item to a List<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

paper wharf
# unique kite .

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