-
Notifications
You must be signed in to change notification settings - Fork 557
feat: NetworkObjectSpawner for dynamically spawning in-scene placed NetworkObjects [MTT-1558] #717
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
Conversation
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs
Outdated
Show resolved
Hide resolved
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs
Outdated
Show resolved
Hide resolved
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SpawnObjectData.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really elegant solution! Something that might be an issue, though, is that now the dynamically-spawned imps are no longer linked to their respective additive scene. So if we move out of it and it gets unloaded, the imps still stay there, but if we come back to it and it gets loaded again, the imps get re-spawned. This means we can have multiple bosses or vandal imps at once
Description
This PR resolves the issue encountered when joining a game session already underway, where the late-joiner would see ghost imps. In-scene placed NetworkObjects were destroyed & despawned on the server, and so the joining client would always load new NetworkObjects which were not synchronized with the server.
Here,
NetworkObjectSpawner
component can be added to a GameObject inside a scene/prefab to spawn a NetworkObject when NetworkSceneManager's OnLoadEventCompleted is invoked. The wrapper is destroyed after the NetworkObject is spawned inside the server, and otherwise on Awake() on clients, to reduce memory buildup.Gizmos have been added as a way to at-a-glance spot NetworkObjects in a scene/prefab that will be spawned. I would love to add meshes as a preview, but in my opinion that's more of a nice-to-have, cosmetic, editor tool.
An extra: VandalImpGraphics had an unnecessary NetworkObject added to it which prevented spawns on the entrance area. This has been removed.
Issue Number(s)
MTT-1558
Contribution checklist