Question by
jharry78 · Jun 17, 2016 at 07:34 AM ·
networkingprefabmultiplayerplayerserver
unet : modify PlayerPrefab in the code
Hello, I'm try to make a multiplayer game but for this i need to change the playerPerfab of the NetworkManager. I try to use the OnServerAddPlayer override function but this doesn't work, my code :
public GameObject[] Players;
public GameObject Select;
public GameObject SpawnPoint;
public int Counter;
// Use this for initialization
void Start () {
Counter = PlayerPrefs.GetInt("Counter");
Select = Players [Counter];
}
public virtual void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
var player = (GameObject)GameObject.Instantiate(Select, SpawnPoint.transform.position , Quaternion.identity);
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
}
// Update is called once per frame
void Update () {
}
Comment
Your answer
Follow this Question
Related Questions
Destroy only player after disconnecting from server 0 Answers
Is there any benefit to calling NetworkTransport.Receive multiple times per tick? 0 Answers
Unet - Where/How to start implementing Host Migration? 1 Answer
Testing my multiplayer with someone across the country 1 Answer
Photon & Unity Question 0 Answers