Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Netcode ghost component

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by optimise, Dec 8, 2022.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    1,795
    Let say I create FooComponent as shown below that value will sync at both client and server but anotherValue is client only. Is this kind of ghost component setup still supported or I should create another BarComponent and move anotherValue to BarComponent? From what I see at 1.0.0-pre.15, I will have weird behavior that FooComponent data is not sync properly.

    public struct FooComponent : IComponentData
    {
    [GhostField]
    public float value;
    public float anotherValue;
    }
     
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    162
    Yep it is! :) Whenever the client receives a snapshot of `FooComponent`, it'll only write to `value`, completely ignoring `anotherValue`. This is true even in prediction + rollback contexts.