Would like some help regarding Networking, I’m pretty new to this thus would be nice to pick your brains on some ideas on how to approach it. I’m of-course using Unity Networking but also Prime31 game center plugin for the matchmaking/inviting friends.
I use prime31 to get the players when all players have been found they send over some info and decide who should be the host of Unity3d Networking server. The host initializes and registers the server.
When server register succeeds the host tells everyone to join the server, when everyone is connected they all load the games first level.
And here starts what I’m trying to figure out how to best control player spawning: My game consists of two teams, team one consists of one player(main character “adam”) team two the “evil enemy” team consists of 3 players(“Enemy00”,“Enemy01” ,“Enemy02”), each enemy player is supposed to spawn a unique character model.
Game is played when the game is over level is to restart and the “Enemy00” has it’s turn to be the main player making the previous main player the new “Enemy00” and etc with the rest of the turn until everyone has had their turn playing as the main player.
**My current possible solution:***Ignore the text coloring, used Code to preserve tabbing
mainMenu
Use Prime31 to find/invite players.
When 4 players are found each client creates(or uses their IP) and sends it to everyone else. Also save your gameCenter name to myName.
When 3 numbers are received compare with your own number if I have the lowest one I will Host the game.
Host registers the server tells everyone to connect to it(ofc send this message with Prime31).
Host when connection = 4 put references to players in vars(playerRef01,playerRef02,playerRef03,playerRef04).
Host RPC's each player: their playerOrder depending on connections[#]
Each client RPC's: their gameCenter name into playerName01 or playerName02.. etc.(Depending on their player order)
Host RPC's: set currentPlayerTurn = 0;
Start the game level
Game started
Host checks currentPlayerTurn using a switch and tells clients to spawn(network.instantiate) specific characters:
case 0:
playerRef01 spawn main player
playerRef02 spawn enemy01
playerRef02 spawn enemy02
playerRef02 spawn Enemy03
case 1:
playerRef02 spawn enemy01
playerRef01 spawn main player
playerRef02 spawn enemy02
playerRef02 spawn enemy03
ETC...
GameOver/TurnOver
Host RPC's: save currentPlayerTurn's score to vars(playerScore01,playerScore02,playerScore03,playerScore04)
Host RPC's: show GameOver/TurnOver slide (if currentPlayerTurn == lastTurn show GameOver/Winner Result)
Host RPC's: increment currentPlayerTurn with 1
I hope I have been able to explain the situation/problem in the correct way since I am really a beginner when it come to this. Any help would be much appreciated!