Skip to content
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

[Sync( SyncFlags.FromHost )]'ed properties get stomped after setting on OnActive #7261

Open
trundlr opened this issue Dec 27, 2024 · 1 comment

Comments

@trundlr
Copy link

trundlr commented Dec 27, 2024

Describe the bug

I'm experiencing an issue where host sync'd properties are getting stomped on joining instances after being set in OnActive. Through my experimentation, I have found this affects all values synced from the host, not just components or GameObjects.

Here is the flow (all run from the host):

  • In GrubsNetworkManager.cs, we use INetworkListener's OnActive to create a Client from a prefab. We clone the prefab, and network spawn it from the joining connection.
  • Then, we call OnNetworkActive on the newly created client. The player prefab is cloned, network spawned through the same connection, and assigned to host sync'd property Player on the Client.
  • This successfully sets, but is stomped a few ticks later, ONLY SOMETIMES, to being null.
  • Attempting to assign other HostSync'd values in OnNetworkActive, even test values like int Test and assigning it 8, will also get stomped in the same way.

Below is a video of this happening. I was more concerned about the networked ConnectionId here, but the same principle applies to all properties being set.

2024-12-27.10-49-43.mp4

To Reproduce

  1. Clone the player-system-improvements branch of Grubs at this commit: https://github.com/apetavern/grubs/tree/797a9c07b261121e4e30461c919727e0c36202e3
  2. Start a game in the beach.scene, and join with a second instance.
  3. If the player cards both populate properly, reconnect on the second client until the second instance player card is blank, as shown in the video.
  4. Logging various HostSync'd properties in OnUpdate will demonstrate that the properties do get set initially, but quickly get stomped.

I have tried even using the HostSync'd property as a backing field for another property, and logging when the property gets set, but clearly this is being stomped from the engine side, since there is nothing from my game code setting this value.

Expected behavior

The HostSync'd properties do not get stomped a few ticks after being set.

Media/Files

No response

Additional context

No response

@trundlr
Copy link
Author

trundlr commented Dec 27, 2024

@kurozael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

No branches or pull requests

1 participant