Question on sync'ing properties (from tutorial)

Super noob question: In the tutorial, we start by sync'ing transform. Great. Then we add color. Ok. But why is it that the mechanism for hooking up the sync'ing of the properties is completely different?

public override void Attached() // when object is live on the network
state.SetTransforms(state.CubeTransform, transform);
state.AddCallback("CubeColor", ColorChanged);

SetTransforms "seems" (it's not really explained in the tutorial) to be a way of setting up auto-sync of a transform property. Great. But for color we need to setup a callback for when the networked property changes, and then when it does, manually update the local property.

Transform seems to have a magic auto-sync ability. Are transforms 1st class and everything else 2nd class? Just wondering why we have two different ways of sync'ing different properties on the same object. Seems weird/inconsistent.

Best Answers


  • Sorry to hijack the thread, but I have a question about the same line of code.

    state.SetTransforms(state.CubeTransform, transform);

    Could you explain this method in a little more detail please. Specifically why this needs to be called on all clients (owner and non-owners and not one or the other) for it to work?
  • I should also note that early on Bolt had kind of a hard-coded, single Transform property as part of state. It later was pulled out into its own property - mainly because sometimes you don't need a transform at all - and sometimes you might want to support multiple transform properties in the same state.
Sign In or Register to comment.