Title: `NetworkObject` `CheckObjectVisibility` doesn't work on client connection · Issue #3185 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub
Open Graph Title: `NetworkObject` `CheckObjectVisibility` doesn't work on client connection · Issue #3185 · Unity-Technologies/com.unity.netcode.gameobjects
X Title: `NetworkObject` `CheckObjectVisibility` doesn't work on client connection · Issue #3185 · Unity-Technologies/com.unity.netcode.gameobjects
Description: Description I want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn: NetworkObject.SpawnWithObservers = false; NetworkObject.Spawn(); this results a spawned object with zero observers...
Open Graph Description: Description I want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn: NetworkObject.SpawnWithObservers = false; NetworkObject.Spawn(); this resu...
X Description: Description I want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn: NetworkObject.SpawnWithObservers = false; NetworkObject.Spawn(); this resu...
Opengraph URL: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/3185
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`NetworkObject` `CheckObjectVisibility` doesn't work on client connection","articleBody":"### Description\n\nI want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn:\n```csharp\nNetworkObject.SpawnWithObservers = false;\nNetworkObject.Spawn();\n```\nthis results a spawned object with zero observers, but when a late-join client connects, the object gets spawned on client. The [documentation](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/#spawning-with-or-without-observers) says this is the intended normal behavior, because it only works at the initial spawning.\n\nThen, the [documentation](https://docs-multiplayer.unity3d.com/netcode/current/basics/object-visibility/#using-visibility) says the `CheckObjectVisibility` will work at both initial spawning and new client connection, so i tried this:\n```csharp\nNetworkObject.CheckObjectVisibility += _ => false;\nNetworkObject.Spawn();\n```\nit did spawn with no observers as the previous approach, but when late-join client connects, it still spawn the object on client.\n\n### Reproduce Steps\n\n1. start server/host\n2. spawn a network prefab with `NetworkObject.CheckObjectVisibility += _ => false;`\n3. start a client and connect to server\n\n### Actual Outcome\n\na spawned object with visibility always set to false still spawns on late-join client\n\n### Expected Outcome\n\na spawned object with visibility always set to false should be invisible to all connected client and future late-join clients\n\n\n### Environment\n\n- OS: [win10]\n- Unity Version: [6000.0.32f1]\n- Netcode Version: [2.1.1]\n","author":{"url":"https://github.com/babaq","@type":"Person","name":"babaq"},"datePublished":"2024-12-29T22:12:19Z","url":"https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/3185"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d87c6fc8-410c-2513-5647-502237d0a60e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFF0:30501:D59B20:120C448:6B005756 |
| html-safe-nonce | 64fe067bd037b1c6d2ed2deaacfc6bcc2513548e3d0687e8607b059f41d79c12 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkYwOjMwNTAxOkQ1OUIyMDoxMjBDNDQ4OjZCMDA1NzU2IiwidmlzaXRvcl9pZCI6IjM4MTI0MzY4MTg4MzAzMTczOTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 02e8ed8731a1c0b988bfab7f592d7f700e3419822b0121e3b6be945305b29539 |
| hovercard-subject-tag | issue:2762422953 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Unity-Technologies/com.unity.netcode.gameobjects/3185/issue_layout |
| twitter:image | https://opengraph.githubassets.com/83d49addf9f371556ed3dc334d5d1a0dd82faca0d1a11c3d7942ffee42fb4194/Unity-Technologies/com.unity.netcode.gameobjects/issues/3185 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/83d49addf9f371556ed3dc334d5d1a0dd82faca0d1a11c3d7942ffee42fb4194/Unity-Technologies/com.unity.netcode.gameobjects/issues/3185 |
| og:image:alt | Description I want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn: NetworkObject.SpawnWithObservers = false; NetworkObject.Spawn(); this resu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | babaq |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/Unity-Technologies/com.unity.netcode.gameobjects git https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git |
| octolytics-dimension-user_id | 426196 |
| octolytics-dimension-user_login | Unity-Technologies |
| octolytics-dimension-repository_id | 116385203 |
| octolytics-dimension-repository_nwo | Unity-Technologies/com.unity.netcode.gameobjects |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 116385203 |
| octolytics-dimension-repository_network_root_nwo | Unity-Technologies/com.unity.netcode.gameobjects |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width