#NetworkServer.Spawn(character) didn't work correctly when new client connect.
1 messages · Page 1 of 1 (latest)
@wanton pier just mainscene
show inspector of your network manager
paste your "MyNetworkManager" in https://pastie.io/ so I can see what you're doing
can you see it?
also you need to clear both of these
click save and put the new URL here
ok
this is the script i create player https://pastie.io/iiufdf.cpp
You don't appear to be calling NetworkServer.AddPlayerForConnection anywhere (that isn't in commented out code)
because these players are not owned by any client .it just run on the serve and i use the client just for watch.so i just use NetworkServer.Spawn(character);
Nothing spawns on client until player is spawned for client
make an empty prefab with network identity and use that for client's player. assign to PlayerPrefab in network manager and turn on auto-create
i tryed use auto-create empty prefab but all the players also didn't spawn on client.old method can see player created after client connect
i don't understand why 
You can do as I suggested or not...up to you
thank you .i will try your method again.
You don't have a Transport assigned either and I don't see anywhere in your code that you're setting it to anything
This code is unnecessary. Mirror will spawn all to client when client gets a player
public void OnServerAddClient()
{
Debug.Log($"New client connected: Synchronizing existing characters...");
// 遍历所有已创建的角色并重新 Spawn
foreach (var character in createdCharacters)
{
if (character != null)
{
NetworkServer.Spawn(character);
}
}
Debug.Log($"Synchronized {createdCharacters.Count} characters to client ");
}
I also don't see where you're calling NetworkClient.RegisterPrefab for anything you're spawning and they're not in this list
it begin to work correctly !!!