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. Dismiss Notice

Question How can I achieve Network Proximity with Netcode for Entities?

Discussion in 'NetCode for ECS' started by OrientedPain, Jun 15, 2023.

  1. OrientedPain

    OrientedPain

    Joined:
    Mar 26, 2018
    Posts:
    37
    Hello Everyone,

    I would like to achieve Network Proximity to allow me to define specific area with range around the entities that will be synced over the network. Entities outside radius of the player for example will not be synced. It will reduce the amount of data sent across the network, something like Network Proximity Checker in (UNet).

    Is this feature existing in NetCode For ECS? Or should I do It by myself? and how?

    Thanks in advance.
     
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    Hey OrientedPain!

    In Netcode for Entities, we call this "Relevancy", and for proximity based solutions specifically, "Relevancy Radius". This specific sub-section of the optimizations.md manual page covers it.

    And our public Asteroids sample makes use of it (example implementation).

    It works by giving you access to a collection (GhostRelevancySet) inside the GhostRelevancy singleton entity on the server, where you can define "is this entity relevant to this connection?" by adding to (or leaving out from) this set.
     
    PolarTron, Opeth001 and OrientedPain like this.
  3. OrientedPain

    OrientedPain

    Joined:
    Mar 26, 2018
    Posts:
    37
    Thank you so much for your help NikiWalker.
     
    NikiWalker likes this.