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 Unity.Entities.ArchetypeChunk entity fragmentation, as we're using the Unity.Entities.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.

    Methods

    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

    Unity.Entities.ISystem
    Unity.Entities.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)