docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostSpawnBuffer

    The GhostSpawnBuffer is the data for a GhostSpawnQueue singleton. It contains a list of ghosts which will be spawned by the GhostSpawnSystem at the beginning of next frame. It is populated by the GhostReceiveSystem and there needs to be a classification system updating after the GhostReceiveSystem which sets the SpawnType so the spawn system knows how to spawn the ghost. A classification system should only modify the SpawnType and PredictedSpawnEntity fields of this struct. InternalBufferCapacity allocated to almost max out chunk memory.

    Implements
    IBufferElementData
    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
    [InternalBufferCapacity(0)]
    public struct GhostSpawnBuffer : IBufferElementData

    Fields

    DataOffset

    Offset im bytes used to retrieve from the temporary SnapshotDataBuffer, present on the GhostSpawnQueue singleton, the first received snapshot from the server.

    Declaration
    public int DataOffset
    Field Value
    Type Description
    int

    DynamicDataSize

    The size of the initial dynamic buffers data associated with the entity.

    Declaration
    public uint DynamicDataSize
    Field Value
    Type Description
    uint

    GhostID

    The ghost id that will be assigned to the new ghost instance.

    Declaration
    public int GhostID
    Field Value
    Type Description
    int

    GhostType

    The index of the ghost type in the GhostCollectionPrefab collection. Used to classify the ghost (GhostSpawnClassificationSystem).

    Declaration
    public int GhostType
    Field Value
    Type Description
    int

    PredictedSpawnEntity

    Entity reference assigned by a classification system, when a predicted spawned entity for a newly received ghost is found. When assigning this HasClassifiedPredictedSpawn should also be set to true. If the referenced entity is different than Unity.Entities.Entity.Null the ghost type must be set to Predicted.

    Declaration
    public Entity PredictedSpawnEntity
    Field Value
    Type Description
    Entity

    ServerSpawnTick

    The tick this ghost was spawned on the server. For any predicted spawning this is the tick that should match since you are interested in when the server spawned the ghost, not when the server first sent the ghost to the client. Using this also means you are not considering ghosts becoming relevant as spawning.

    Declaration
    public NetworkTick ServerSpawnTick
    Field Value
    Type Description
    NetworkTick

    SpawnType

    The type of ghost to spawn. Based on the spawn type, some components may be enable/disabled or removed from the instantiated ghost.

    Declaration
    public GhostSpawnBuffer.Type SpawnType
    Field Value
    Type Description
    GhostSpawnBuffer.Type

    Properties

    HasClassifiedPredictedSpawn

    Should be set to true when a ghost classification system has processed this particular ghost spawn instance. It will then not be processed again in a system running later in the frame (like the default classification system).

    Declaration
    public bool HasClassifiedPredictedSpawn { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ToFixedString()

    Helper.

    Declaration
    public FixedString512Bytes ToFixedString()
    Returns
    Type Description
    FixedString512Bytes

    Formatted informational string.

    Implements

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