docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostDistancePartitioningSystem

    Automatically adds the GhostDistancePartitionShared shared component to each ghost instance on the server (a structural change), and then updates said component - for each ghost instance - if its Unity.Transforms.LocalTransform.Position changes to a new tile (which is also a structural change, as it needs to update a shared component value). It does this every tick.

    Implements
    ISystem
    ISystemStartStop
    ISystemCompilerGenerated
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation, WorldSystemFilterFlags.Default)]
    [UpdateInGroup(typeof(GhostSimulationSystemGroup), OrderFirst = true)]
    [BurstCompile]
    public struct GhostDistancePartitioningSystem : ISystem, ISystemStartStop, ISystemCompilerGenerated
    Remarks

    This system only operates if it detects the existence of the GhostDistanceData configuration singleton component within a ServerWorld.

    Note that adding the GhostDistancePartitionShared shared component to each ghost instance will almost certainly exacerbate ArchetypeChunk entity fragmentation, as we're using the ArchetypeChunk system to spatially partition ghost instances. I.e. If there are (for example) just two ghosts of the same archetype within a specific tile, the maximum utilization of their chunk will by 2.

    Note that, due to; a) the number of changed positions this system needs to check; b) the frequency of structural changes created by this system; and c) the fragmentation caused by the shared component itself, the impact of enabling importance scaling should be measured, and benchmarked against other possible solutions.

    Properties

    AutomaticallyAddGhostDistancePartitionSharedComponent

    If true (the default), this system will add the GhostDistancePartitionShared shared component to all server ghost instances that meet filtering criteria (Unity.Transforms.LocalTransform etc).

    Declaration
    public static bool AutomaticallyAddGhostDistancePartitionSharedComponent { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    Set to false if you want to use the shared component as a filter, allowing you to only enable importance scaling on a subset of ghost instances. You must therefore add the component yourself.

    Methods

    CalculateTile(in GhostDistanceData, in float3)

    Calculates the tile value for the specified position.

    Declaration
    public static int3 CalculateTile(in GhostDistanceData ghostDistanceData, in float3 position)
    Parameters
    Type Name Description
    GhostDistanceData ghostDistanceData

    The ghost distance data

    float3 position

    The positon

    Returns
    Type Description
    int3

    The tile value for the specified position

    OnCreate(ref SystemState)

    Declaration
    [BurstCompile]
    public void OnCreate(ref SystemState state)
    Parameters
    Type Name Description
    SystemState state

    OnCreateForCompiler(ref SystemState)

    Declaration
    public void OnCreateForCompiler(ref SystemState state)
    Parameters
    Type Name Description
    SystemState state

    OnStartRunning(ref SystemState)

    Declaration
    [BurstCompile]
    public void OnStartRunning(ref SystemState state)
    Parameters
    Type Name Description
    SystemState state

    OnStopRunning(ref SystemState)

    Clean up any/all GhostDistancePartitionShared components that we've added. Note: This will not de-frag fragmented chunks automatically.

    Declaration
    [BurstCompile]
    public void OnStopRunning(ref SystemState state)
    Parameters
    Type Name Description
    SystemState state

    OnUpdate(ref SystemState)

    Declaration
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    Parameters
    Type Name Description
    SystemState state

    Implements

    ISystem
    ISystemStartStop
    Unity.Entities.ISystemCompilerGenerated
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)