Question by
revolution5 · Apr 26, 2017 at 06:12 PM ·
networkingspawnpointsnetwork.instantiate
Respawning a network Player after everyone joins
I am making a simple online team game where all the players join the match on either one of two teams....Once the lobby is full they will spawn on opposite sides of the level and begin to play.
How would I go about spawning the players in separate spots so they are not on top of each other...So basically, I would have four spawn spots for team red, and four for team blue...I want to avoid red spawning on red etc...
Another option I was thinking was to create two separate round robins, if anyone knows anything about this or another method please pass it on
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking;
void Start () {
}
public void SelectRed(int teamSelect){
Debug.Log (teamSelect);
teamSelect = 1;
characterChose = teamSelect;
Debug.Log ("character before sapwn" + characterChose);
}
public void SelectBlue(int teamSelect){
Debug.Log (teamSelect);
teamSelect = 0;
characterChose = teamSelect;
Debug.Log ("character before sapwn" + characterChose);
}
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId){
Debug.Log ("character after sapwn" + characterChose);
if(characterChose == 1){
GameObject player = (GameObject)GameObject.Instantiate (red, spawnLocation, Quaternion.identity);
NetworkServer.AddPlayerForConnection (conn, player, playerControllerId);
}
if(characterChose == 0){
GameObject player = (GameObject)GameObject.Instantiate (blue, spawnLocation, Quaternion.identity);
NetworkServer.AddPlayerForConnection (conn, player, playerControllerId);
}
}
} Thanks
Comment