Question by
ClownOfMadness · Aug 21, 2021 at 09:41 AM ·
networkingmirror
Different Prefab for each new connected client?
Trying to make it so that the second player joining the server would receive different prefab. This is what I believed would do the job:
public class CustomNetwork : NetworkManager
{
public Transform player1Position;
public Transform player2Position;
public GameObject player1Prefab;
public GameObject player2Prefab;
public override void OnServerAddPlayer(NetworkConnection conn)
{
if (numPlayers == 0)
{
Transform start1 = player1Position;
GameObject player1 = Instantiate(player1Prefab, start1.position, start1.rotation);
NetworkServer.AddPlayerForConnection(conn, player1);
}
else
{
Transform start2 = player2Position;
GameObject player2 = Instantiate(player2Prefab, start2.position, start2.rotation);
NetworkServer.AddPlayerForConnection(conn, player2);
}
}
}
But as result i can see 2 different player in the host client (and can move the player 1), but on the connected client I see 0 players, not mine and not the host.
This is the error I receive:
fusa0.png
(31.0 kB)
Comment
Your answer
Follow this Question
Related Questions
[Mirror Networking] How can i add a NetworkRigidbody component to an object ? 0 Answers
Multiplayer Networking Leap Motion with Mirror 1 Answer
Trouble spawning objects on server in Mirror 0 Answers
Mirror - attribute assigned to server, but not client. 0 Answers
[Forum bugged, can't delete] 0 Answers