Skip to content

Incorrect SyncVar behaviour in host mode #4126

Description

@Bod9001

Describe the bug
so, after spending a bunch of time debugging

When you host,
when an object spawns in it generates a spawn payload message, however this is immediately when the object is created so only SyncVars that are set in the wake are initialised properly, whilst things that would be post-spawn
e.g

var object =  spawn
object.setup(data)

would be not caught in the initial state,
due to the host mode, processing SpawnMessage, and the associated SyncVars, that means any values that were set post spawn message Serialisation would be set to default value (Since it does all SyncVars),
and then since host mode ignores EntityStateMessage,
that would have the serialised data of what you set it to after spawning it, resulting in the host getting set to an incorrect state

this combines with another issue

Where if you set a SyncVar in host mode, before receiving the spawn message, so in the same frame your spawning it it won't directly trigger hook function

if (NetworkServer.activeHost && !GetSyncVarHookGuard(dirtyBit) && NetworkClient.spawned.ContainsKey(netIdentity.netId))

since it's not yet in NetworkClient.spawned

tested on Commit 0eab9bd (latest to commit as of writing)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions