Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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:
    2,135
    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:
    331
    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.