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
- [macOS] Secondary display rendering incorrect target and flickering when building for Multi-Display
- "Create Empty Child" Option Creates Root Object When No Parent Is Selected
- Freeze/Crash when entering Play Mode in a specific project
- Lack of documentation regarding VFX Ray Tracing support
- Shader properties do not appear on the GameObject when switching ShaderGraphs during runtime in the Player
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.