docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GhostObjectPredictionSwitchExtension

    Extension methods to switch a GhostObject between predicted and interpolated mode on the client.

    Inheritance
    object
    GhostObjectPredictionSwitchExtension
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.Netcode
    Assembly: Unity.NetCode.dll
    Syntax
    public static class GhostObjectPredictionSwitchExtension

    Methods

    ConvertToInterpolated(GhostObject, float)

    Convert a predicted ghost to an interpolated ghost. The ghost must support both interpolated and predicted mode, and it cannot be owner predicted. Owner predicted ghost are automatically changing prediction mode when the owner is changed.

    Declaration
    public static bool ConvertToInterpolated(this GhostObject self, float transitionTime = 0)
    Parameters
    Type Name Description
    GhostObject self

    The ghost to convert.

    float transitionTime

    Duration in seconds of the visual smoothing applied during the transition. 0 disables smoothing.

    Returns
    Type Description
    bool

    true if the conversion was requested, false if the ghost is not allowed to switch mode.

    Remarks

    If this method is called from a MonoBehaviour, and the entity is associated to a GhostObject, all the PredictionUpdate(PredictionUpdateContext) are not going to be invoked this frame. If this method is called from a System, running after the GhostPredictionSmoothingSystem, the ghost conversion will occur the next frame, thus the ghost will be still be seen as predicted for the whole world update.

    From a GhostBehaviour perspective the ghost is going to be seen as: - `Predicted` in the next Update - `Interpolated` in the next LateUpdate

    ConvertToPredicted(GhostObject, float)

    Convert an interpolated ghost to a predicted ghost. The ghost must support both interpolated and predicted mode, and it cannot be owner predicted. Owner predicted ghost are automatically changing prediction mode when the owner is changed.

    Declaration
    public static bool ConvertToPredicted(this GhostObject self, float transitionTime = 0)
    Parameters
    Type Name Description
    GhostObject self

    The ghost to convert.

    float transitionTime

    Duration in seconds of the visual smoothing applied during the transition. 0 disables smoothing.

    Returns
    Type Description
    bool

    true if the conversion was requested, false if the ghost is not allowed to switch mode.

    Remarks

    If this method is called from a MonoBehaviour, and the entity is associated to a GhostObject, all the PredictionUpdate(PredictionUpdateContext) are going to be invoked this frame. If this method is called from a System, running after the GhostPredictionSmoothingSystem, the ghost conversion will occur the next frame, thus the ghost will be still be seen as interpolated for the whole world update.

    From a GhostBehaviour perspective the ghost is going to be seen as: - `Interpolated` in the next Update - `Predicted` in the next LateUpdate

    In This Article
    Back to top
    Copyright © 2026 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)