-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HostSync, Sync]
property not getting set on host
#6467
Comments
If you remove the |
[HostSync] means the host is the authority for that property, so only the host should be able to set it, right? I'm not sure that having both HostSync and Sync on the same property is supported or makes sense. |
The docs say that the two attributes can be used together to have a property that can be set by the host and the owner. https://docs.facepunch.com/s/sbox-dev/doc/sync-properties-jKFHwTGVgR#h-hostsync-attribute |
It feels silly to have both. We should just be able to pass params into a single Sync attribute. |
Hmm... might be a better idea than what it currently is. For instance, if an enum is provided to an attribute, more people might be aware of this functionality. |
My mistake, thanks for the correction. |
Adding a protected override async Task OnLoad()
{
if ( !Sandbox.Game.IsPlaying )
return;
if ( !GameNetworkSystem.IsActive )
GameNetworkSystem.CreateLobby();
DelaySpawn(Connection.Local);
await GameTask.CompletedTask;
}
async void DelaySpawn(Connection connection)
{
await Task.Frame();
var clientObj = SceneUtility.GetPrefabScene( ClientPrefab ).Clone();
clientObj.NetworkSpawn( connection );
var client = clientObj.Components.Get<Client>();
client.AssignConnection( connection );
// Option #1
// The pawn component MUST have PawnAttribute.
client.AssignPawn<SpectatePawn>();
// Option #2
// The pawn component does NOT need PawnAttribute in this case.
// client.AssignPawn<SpectatePawn>(SpectatePrefab);
} |
isn't Sync and HostSync unreliable |
I think in this case it may be that the Pawn doesn't exist yet when the Sync property is received on the host. Since you're creating the object on the client and then network spawning it - so when the host gets the Sync property value (Id) there is no GameObject yet. This may be that we need to introduce some kind of handle. |
What is interesting though is if you remove the |
Describe the bug
I have a
[HostSync, Sync]
property that is NOT getting set for the host when a non-host client sets the value.To Reproduce
https://github.com/Small-Fish-Dev/pawns/tree/host-sync
Pawn
value of the hostPawn
value synced of the new connecting clientExpected behavior
In the same project, the value of
should get synced for the host.
Media/Files
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: