When a client connects to the host, two player prefabs are created on the host screen, but no player prefabs are generated on the client screen.
Also, the following error is sent to the client side: [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 3, but that trigger was not received within within 1 second(s).
When you say this, do you mean that when the client connects 2 new players are instantiated in that moment, or do you refer to the total number of players visible on the screen? (1 of the host, 1 of the client?)
Also, did you set the Player prefab in the NetworkManager’s prefab?
When the host starts the game, the host’s Player Prefab is instantiated, and when the client connects to the host, the client is instantiated on the host’s screen.
However, neither the host nor itself is instantiated on the client side.
I have confirmed that the PlayerPrefab has been set to NetworkManager.
Does the PlayerPrefab also have the NetworkObject component?
Can you try creating an empty player prefab with just a cube, and spawn it as the player to see if the issue reproduces? It might be caused by some scripts on your Player’s object
I try PlayerPrefab with just a cube(add NetworkObject).
However, the problem remained largely the same. PlayerPrefab still spawn only on the host side.
Mostly, I mean the error message is gone. [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 3, but that trigger was not received within within 1 second(s).
By the way, I got the following error on the host side. Any hints for solving the problem? Exception: GetSceneOriginHandle called when SceneOriginHandle is still zero but the NetworkObject is already spawned!
I tried using UnityTransport, but the result did not change.
The host and client PlayerPrefabs are instantiated on the host side, but neither is instantiated on the client side.
NetworkManager.Singleton.StartClient()
I’m doing the above inside Start(), could this be the problem?
I’m wondering if it’s a problem that the NetworkManager specification calls StartClient() at the beginning of the Scene.
Actually, at the beginning of development, the HUD was displayed at the beginning of the Scene, and the implementation was to select the host and client from there. it was working fine.
This problem occurred after removing the HUD and implementing an implementation that automatically determines the host and client after the scene changes.
It could be. If you’re doing this at start, when do you start the Host/Server?
it’s probably a timing problem then. You can try adding a coroutine to connect a few seconds later. I wonder if there’s anything you could wait for instead (I.E: an event…)
I tried StartClient() 10 seconds after the scene started, but the result was the same.
I noticed that NetworkManager is multiple instantiated. A Google search seems to show that the same issue is happening to different people. I’m not sure if this is the reason why the PlayerPrefab is not instantiated on the client side, but it’s possible and I’ll look into it.
Umm…
The problem of multiple instances of NetworkManager being instantiated has been resolved. This is simply because the scene where the NetworkManager is placed was loaded every time a SteamAPI callback came.
I tried with a single NetworkManager, but the result was the same.
It seems that the above error is the cause.
However, the cause is unknown.
I tried it with a simple scene with exactly the same NetworkManager and GameManager and it works fine. The PlayerPrefab uses exactly the same.
Do you know the reason?