简体   繁体   中英

Diffrent Prefab in Network Lobby Manager Unity3D

I want to let each client to select their player prefab in lobby and when game start I want to instantiate selected prefab for client. I defined variable in LobbyManager but it's not working. It's always with the same host. How can I solve this?

Here is my code:

 public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
    {
        Debug.LogError(playerPrefabIndex + "Ins Index");
        GameObject playerPrefab = (GameObject)Instantiate(spawnPrefabs[playerPrefabIndex]);
        NetworkServer.Spawn(playerPrefab);
        return playerPrefab;
    }

为了解决这个问题,我实例化没有模型的预制件,并通过syncvar传递预制件ID,然后在所有客户端上附加到播放器对象的脚本中调用SetModelById()。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM