Repository navigation
Commit 5982716
authored
fix: only send scene migrations to observers, and spawn a NetworkObject shown after a migration in its authority's scene (#4185)
* fix: only send scene migrations to observers, and spawn a NetworkObject shown after a migration in the server's scene
ObjectSceneChanged was sent to every connected client, including clients that did not observe the migrated NetworkObjects and had never spawned them, which logged "Trying to synchronize NetworkObjectId but it was not spawned". In client-server mode it is now only sent to clients that observe at least one migrated NetworkObject, and each client is only sent the NetworkObjects it observes. Distributed authority is unchanged.
A client that starts observing a NetworkObject with NetworkShow after the NetworkObject migrated into another scene was never sent that migration, and instantiated the NetworkObject in its active scene. The client now moves a spawned NetworkObject into its server-side scene, as it already does for NetworkObjects that are part of its initial synchronization.
* fix: apply the scene migration fixes in distributed authority mode
Distributed authority still sent a scene migration to every client, so clients that did not observe a migrated NetworkObject logged "Trying to synchronize NetworkObjectId but it was not spawned", and a NetworkObject shown after it migrated spawned in the client's active scene.
The owner now only sends a migration to the clients that observe a migrated NetworkObject, as in client-server mode. The CMB service's own copy still includes every migrated NetworkObject, and a migration the DAHost forwards is not filtered again. A NetworkObject a distributed authority client spawns when it is shown is moved into its owner's scene. NetworkObjectSceneMigrationObserverTests now also runs as DAHost.
* chore: correct the comment on when the CMB service is sent a scene migration
Only the session owner sends the CMB service its own copy of a migration; a client that is not the session owner does not tell the service about objects only it observes.
* Implement UseCMBService method for Rust server
Added method to disable CMB service for Rust server compatibility.
* Fix XML summary comment formatting in test file
* Fix summary comment formatting in test file1 parent fdadb7d commit 5982716
6 files changed
Lines changed: 279 additions & 25 deletions
File tree
- com.unity.netcode.gameobjects
- Runtime
- Messaging/Messages
- SceneManagement
- Tests/Runtime/NetworkObject
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
| |||
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
209 | 222 | | |
210 | 223 | | |
211 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2253 | 2253 | | |
2254 | 2254 | | |
2255 | 2255 | | |
2256 | | - | |
2257 | | - | |
2258 | | - | |
2259 | | - | |
2260 | | - | |
2261 | | - | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
2262 | 2259 | | |
2263 | | - | |
2264 | | - | |
2265 | | - | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
2266 | 2281 | | |
2267 | | - | |
2268 | | - | |
2269 | | - | |
2270 | | - | |
2271 | | - | |
2272 | | - | |
2273 | | - | |
2274 | | - | |
2275 | | - | |
2276 | | - | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
2277 | 2289 | | |
2278 | 2290 | | |
2279 | 2291 | | |
| |||
2992 | 3004 | | |
2993 | 3005 | | |
2994 | 3006 | | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
2995 | 3027 | | |
2996 | 3028 | | |
2997 | 3029 | | |
| |||
3056 | 3088 | | |
3057 | 3089 | | |
3058 | 3090 | | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
3059 | 3108 | | |
3060 | 3109 | | |
3061 | 3110 | | |
3062 | 3111 | | |
3063 | 3112 | | |
3064 | 3113 | | |
3065 | | - | |
| 3114 | + | |
3066 | 3115 | | |
3067 | 3116 | | |
3068 | 3117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1201 | 1201 | | |
1202 | 1202 | | |
1203 | 1203 | | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
1204 | 1216 | | |
1205 | 1217 | | |
1206 | 1218 | | |
| |||
1224 | 1236 | | |
1225 | 1237 | | |
1226 | 1238 | | |
1227 | | - | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1228 | 1254 | | |
1229 | 1255 | | |
1230 | 1256 | | |
| 1257 | + | |
1231 | 1258 | | |
1232 | 1259 | | |
1233 | 1260 | | |
1234 | | - | |
1235 | | - | |
| 1261 | + | |
| 1262 | + | |
1236 | 1263 | | |
1237 | | - | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
1238 | 1268 | | |
1239 | 1269 | | |
1240 | 1270 | | |
| |||
0 commit comments