Client does not spawn.

Hello,

Sorry for the poor English.

I’m using Steamworks.NET and SteamNetworkingTransport to create a multiplayer game.
Stemworks.NET: https://steamworks.github.io/
SteamNetworkingTransport: https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/Transports/com.community.netcode.transport.steamnetworking

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).

Anyone know the cause and how to fix it?

Thank you.

Hi! it seems an issue similar to the one in this post . Maybe the information there can help you?

thank you for your reply.

I have checked that post, but it seems different from my problem.
In my case, the Player Prefab is not spawn on the client side.

Maybe there is a problem with the SteamNetworkingTransport I’m using, so I’m investigating it, but I’m not good enough to solve the problem.

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?

Sorry for my lack of explanation.

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.

  1. Does the PlayerPrefab also have the NetworkObject component?
  2. 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

Thank you for your support.

  1. Yes, PlayerPrefab has NetworkObject Component.
  2. 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!

Thank you for your answers!

What NGO version are you using? You could try updating to the most recent one (1.1.0)

NGO version was using 1.0.1.
I just updated to 1.1.0 and tried again, but the result was the same.

I found myself struggling with this problem for about a week. lol

Is it possible that this issue relies on a custom transport?
In that case, I’m thinking of changing the game’s network from the ground up. . .

it could be, does the error appear if you use the default Unity transport?

thank you so much for your long time support.

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…)

Host/Client: At scene start
But the host starts the scene first. The client starts the scene after a delay.

I started the StartClient() with a delay of 100 frames from the beginning of the scene, but the result was the same:(

I can’t think of any other reason. . .

100 frames is a very little amount, and machine-dependent. I’d recommend waiting for a 5+ seconds (for testing purposes)

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.

  1. You should definitely have only 1 NetworkManager
  2. Can you try re-implementing the UI selection? If it solves the issue, then there’s probably a timing problem somewhere in your own code
  1. I tried only 1 NetworkManager.
    2.I will try it later.
    I found an error that might help. It seems to be happening inside StartHost().

NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.NetworkBehaviour.InitializeVariables () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkBehaviour.cs:607)
Unity.Netcode.NetworkBehaviour.InternalOnNetworkSpawn () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkBehaviour.cs:465)
Unity.Netcode.NetworkObject.InvokeBehaviourNetworkSpawn () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkObject.cs:914)
Unity.Netcode.NetworkSpawnManager.SpawnNetworkObjectLocallyCommon (Unity.Netcode.NetworkObject networkObject, System.UInt64 networkId, System.Boolean sceneObject, System.Boolean playerObject, System.UInt64 ownerClientId, System.Boolean destroyWithScene) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Spawning/NetworkSpawnManager.cs:587)
Unity.Netcode.NetworkSpawnManager.SpawnNetworkObjectLocally (Unity.Netcode.NetworkObject networkObject, System.UInt64 networkId, System.Boolean sceneObject, System.Boolean playerObject, System.UInt64 ownerClientId, System.Boolean destroyWithScene) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Spawning/NetworkSpawnManager.cs:489)
Unity.Netcode.NetworkSpawnManager.ServerSpawnSceneObjectsOnStartSweep () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Spawning/NetworkSpawnManager.cs:755)
Unity.Netcode.NetworkManager.StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1182)
GameManager.StartHost () (at Assets/GameManager.cs:57)
GameManager.Start () (at Assets/GameManager.cs:33)

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?