Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How do local groups?

Discussion in 'Netcode for GameObjects' started by Volbran, Jun 8, 2022.

  1. Volbran

    Volbran

    Joined:
    Feb 24, 2020
    Posts:
    16
    I don't need 1000 players in one place, I want to divide them into groups of 50 but on the same server. How to make clients receive data not from all other clients, but only from assigned ones? We would not have 1000 * 1000 data, but only 50 * 1000
     
  2. CosmoM

    CosmoM

    Joined:
    Oct 31, 2015
    Posts:
    199
    Use ClientRpcParams. Have your ClientRpc method take an additional optional parameter
    ClientRpcParams clientRpcParams=default
    , then when calling this ClientRpc do something like this:

    Code (CSharp):
    1. ClientRpcParams clientRpcParams=new ClientRpcParams(){Send=new ClientRpcSendParams{TargetClientIds=new ulong[]{clientId1,clientId2,clientId3}}};
    and pass it to the method call. Here
    clientId1,clientId2,clientId3
    are any number of client ids that you want to receive this ClientRpc call. Be sure to cache the ClientRpcParams and/or ClientRpcSendParams though, or you'll get garbage collection spikes.
     
  3. Volbran

    Volbran

    Joined:
    Feb 24, 2020
    Posts:
    16
    Wow. This should help. Thanks a lot