Hey. Anyone know any way of getting all the players near a x y z position? Say i have a XYZ Vector3. Is it possible to get all the players in a radius of 10 around that Vector3?
[DOUBLEPOST=1520585309][/DOUBLEPOST]@Wulf can you move to the Rust Development section please.
Getting players near x y z position?
Discussion in 'Rust Development' started by Sonny-Boi, Mar 9, 2018.
-
There are 2 ways
- Raycasting (best way, faster)
- Looping through player list and checking Vector3.Distance() (easiest way) -
Raycasting (in this case likely SphereCast), as Ryan said, is probably the best way for you to do that.
Here is a link to the UnityEngine documentation for a SphereCast: Unity - Scripting API: Physics.SphereCastAll
Altough that depends on the context.
If you are trying to track all players inside that radius and constantly update it, I'd recommend using a GameObject with a SphereCollider (as trigger) instead. -
-
-
what about
Code:List<BasePlayer> players = new List<BasePlayer>(); Vis.Entities<BasePlayer>(new Vector3(x,y,z), 10, players);
this will store all BasePlayers in the list u specify at the endLast edited by a moderator: Mar 11, 2018