docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostInstance

    Component signaling an entity which is replicated over the network

    Implements
    IComponentData
    IQueryTypeParameter
    IEquatable<GhostInstance>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    public struct GhostInstance : IComponentData, IQueryTypeParameter, IEquatable<GhostInstance>

    Fields

    ghostId

    The id assigned to the ghost by the server. When a ghost is destroyed, its id is recycled and can assigned to new ghosts. For that reason the ghost id cannot be used as a unique identifier. The ghostId, spawnTick pair is instead guaratee to be unique, since at any given point in time, there can be one and only one ghost that have a given id that has been spawned at that specific tick.

    Declaration
    public int ghostId
    Field Value
    Type Description
    int

    ghostType

    The ghost prefab type, as index inside the ghost prefab collection.

    Declaration
    public int ghostType
    Field Value
    Type Description
    int

    spawnTick

    The tick the entity spawned on the server. Together with ghostId is guaranteed to be always unique.

    Declaration
    public NetworkTick spawnTick
    Field Value
    Type Description
    NetworkTick

    Methods

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    Equals(GhostInstance)

    Declaration
    public bool Equals(GhostInstance other)
    Parameters
    Type Name Description
    GhostInstance other
    Returns
    Type Description
    bool

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    ToFixedString()

    Returns a human-readable GhostComponent FixedString, containing its values.

    Declaration
    public FixedString128Bytes ToFixedString()
    Returns
    Type Description
    FixedString128Bytes

    A human-readable GhostComponent FixedString, containing its values.

    Operators

    operator ==(GhostInstance, GhostInstance)

    Declaration
    public static bool operator ==(GhostInstance left, GhostInstance right)
    Parameters
    Type Name Description
    GhostInstance left
    GhostInstance right
    Returns
    Type Description
    bool

    implicit operator SpawnedGhost(in GhostInstance)

    Implicitly convert a GhostComponent to a SpawnedGhost instance.

    Declaration
    public static implicit operator SpawnedGhost(in GhostInstance comp)
    Parameters
    Type Name Description
    GhostInstance comp

    Ghost component to convert

    Returns
    Type Description
    SpawnedGhost

    Converted ghost component to SpawnedGhost.

    operator !=(GhostInstance, GhostInstance)

    Declaration
    public static bool operator !=(GhostInstance left, GhostInstance right)
    Parameters
    Type Name Description
    GhostInstance left
    GhostInstance right
    Returns
    Type Description
    bool

    Implements

    IComponentData
    IQueryTypeParameter
    IEquatable<T>
    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)