- Home /
Lobby - Trouble with custom feature
Hi guys,
So I'm losing my mind on, what it seems, a basic feature...
I want to use the lobby system because it is exactly what I need, this kind "party" creation. Actually I'm only working in local.
I have integrated the Unity project that set all the basics to use the lobby system. It's working well.
Now, I try to tweak a bit the Lobby panel (where the player connects before starting the game). I want that the lobby creator (let's call it admin) will be able to select a map and all the other player just see the name of the selected map in a Text UI element.
My first tries was to create the bottom bar in the scene but I had trouble to make it work over the network. (Worked well on local though).
So I thought that I need to spawn it by the server but still got issue understanding the logic behind all the Network stuff of Unity. And damn I can't find anything that do something like that on the internet.
So now I have a prefab bottomBar with a networkIdentity set on Client Authority with this component attached :
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
namespace ConsiliumLobby {
public class Lobby_CMPT_BottomBar : NetworkBehaviour {
Lobby_CMPT_Manager manager;
// UI Elements of the bar
public GameObject mapSelectionButtonGo;
// We need the gameObject to be able to hide it completly
public Text selectedMapText;
Button mapSelectionButton;
public override void OnStartClient() {
base.OnStartClient();
manager = Lobby_CMPT_Manager.s_Singleton;
mapSelectionButton = mapSelectionButtonGo.GetComponent<Button>();
SetupLocalPlayer();
}
void SetupLocalPlayer() {
if (isServer) { // Test to know if it's the creator of the party
mapSelectionButton.onClick.RemoveAllListeners();
mapSelectionButton.onClick.AddListener(manager.OpenMapSelPanel);
} else { // Standard player setup
mapSelectionButtonGo.SetActive(false);
}
}
}
}
For the moment I'm just trying to make the button working. Hiding it if it's not the host and if it's the host put in place the listener for the onClick event.
I can't find the right place to spawn it in the NetworkLobbyManager. I have tried in the OnStartHost method but in this place the NetworkServer (for spawning) is not active... I just can't get it.
And my other tries with this logic was on the callback when client connects to the server. But I think that a spawned object don't need to be spawned again for every client.
I try to do the same as the lobby player, but it seems that it still manage the spawn of them differently, and I can't find what I'm missing.
The question is pretty hard to define but I read the documentation and the API a lot of times without understanding how to be able to do what I want.
Does someone already done something like that ?
And maybe can someone answer these few questions : - If I spawn a prefab on the server and later a client connect. What do I need to do ? Or Unity manage to spawn it automatically ? - If an object already exist in the scene, is it local or networked ? I mean could I use this logic or my spawn obsession is right ?
I hope that a clever man or woman out there will understand my struggle. Unity Answer is my last chance before falling into darkness of incomprehension.
Sorry for my english, it may not be perfect.
Thanks in advance, and do not hesitate to ask question, it may help me describe the problem and my goal.
Kind regards,
Lionel
Answer by Lionel_Leeser · Aug 19, 2017 at 03:23 PM
Bump
if someone already deal with that please help.
Thanks everybody !
Your answer
![](https://koobas.hobune.stream/wayback/20220612132838im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Creating Spaceteam style peer-to-peer lobby 0 Answers
Unity networking tutorial? 6 Answers
What can prevent a prefab network instantiation? 0 Answers
Network Lobby doesnt work after update 0 Answers