- Home /
how to Instantiate each Player at specific different position in multiplayer game?
I'm developing a 2D Multiplayer Poker Game. I'm stuck at a single point. I've already done Master Server and GMS programming using peer-to-peer hybrid model. It's successfully Creating new server and players can join other available games created by other players. But while in game screen mode, in game screen programming, as soon as the player joins a game/lobby/private game, how to position the player's game object to the specific empty position at the table. Meaning, how to set the new player joining the table automatically to the place empty. It's a simple stuff but I'm not able to get it. May be somebody can help!
Answer by Minizinger · Nov 28, 2013 at 05:24 PM
In my game I have only 2 players and spawning them using isServer/isClient parameter. For more players you need server to give new id for each connected players using OnPlayerConnected, like:
int _server_connectedPlayers = 0;
void OnPlayerConnected(NetworkPlayer player){
_server_connectedPlayers++;
networkView.RPC("spawnPlayer", player, _server_connectedPlayers);
}
[RPC]
void spawnPlayer(int id){
Network.Instantiate(PlayerPrefabGoesHere, GameObject.Find("SpotNumber" + id.ToString()).transform.position, GameObject.Find("SpotNumber" + id.ToString()).transform.rotation, id);
}
thank $$anonymous$$izinger...but I want to spawn the players dynamically into the position they choose!
Your answer
Follow this Question
Related Questions
Wait until slowest player loaded... 0 Answers
Unhandled message 65 from local ip. 0 Answers
Networked FPSControllers - All players move 1 Answer
Sending A Variable Over The Network 1 Answer