1. 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.
     
  2. There are 2 ways
    - Raycasting (best way, faster)
    - Looping through player list and checking Vector3.Distance() (easiest way)
     
  3. 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.
     
  4. Ok, so what im tryna do is prevent players spawning near each other. Basically when i call Spawns Database im going to check if players are near the XYZ position. Sounds like Raycasting is the way to go.
     
  5. Indeed.
     
  6. 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 end
     
    Last edited by a moderator: Mar 11, 2018