Search Issue Tracker
Won't Fix
Votes
0
Found in [Package]
1.7.0
Issue ID
NCCBUG-221
Regression
No
[NetCode for GameObject] SpawnAsPlayerObject does not change NetworkManager.Singleton.LocalClient.PlayerObject when the GameObject is instantiated right after the Host is started
Reproduction steps:
1. Open the attached project “NgoTest”
2. Open the “Assets/Scenes/NgoTest” Scene
3. Enter the Play mode
4. In the Game view click the “Host - Spawn Immediately” button
5. Inspect the Console window
Expected result: The console outputs the “PlayerObject.name= Cube, PlayerObjectInOwnedObjects= Cube” message after instantiating the Player object
Actual result: The console keeps outputting the “PlayerObject.name= PlayerSpawner(Clone), PlayerObjectInOwnedObjects= PlayerSpawner(Clone)” message after instantiating the Player
Reproducible with: 1.4.0 (2022.3.12f1), 1.7.0 (2021.3.32f1, 2022.3.12f1, 2023.1.19f1, 2023.2.0b16, 2023.3.0a12)
Reproducible on: macOS 13.5.2
Not reproducible on: No other environment tested
Note: This issue is not reproducible if the Player object is instantiated after some delay
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Volumetric fog shader variants are missing from build when "Strict Shader Variant Matching" is disabled
- Unnecessary modifications clutter the Scene when using a RectTransform driven by a LayoutGroup in a Prefab
- Files in the target folder are deleted without a proper warning when building an iOS project
- Character animation freezes when toggling animator on/off in a coroutine
- Certain textures are incorrectly marked in the render pass list when observed through Render Graph Viewer
Resolution Note:
We wanted to clarify that the issue you've encountered is not a defect but rather a specific functionality of NGO and the Host startup sequence. Our team has thoroughly reviewed the reported concern, and it aligns with the intended behaviour of the application.
Since the host is not yet finished starting up, changing the host's player object within the player spawn will result in the results described.
There are 3 valid ways to handle this type of scenario:
- Pre-registration of the NetworkManager.OnServerStarted event prior to invoking NetworkManager.StartHost; Host player object is updated once the NetworkManager has completed the start up process.
- Registration of the NetworkManager.OnServerStarted event within the PlayerSpawner.OnNetworkSpawn method; Host player object is updated once the NetworkManager has completed the start up process.
- Delaying the the assignment of a new host player object by 1 frame using the Coroutine approach.
All three approaches are valid ways to handle this particular scenario where the default player prefab spawns a new player NetworkObject.