Unity-Technologies / com.unity.services.samples.game-lobby

A sample showcasing a minimal implementation of a lobby experience using the Lobby and Relay packages.
Other
198 stars 66 forks source link

Help With Netcode Sycronization And Other Questions #40

Open Mid-D-Man opened 1 year ago

Mid-D-Man commented 1 year ago

hello, so i have a couple of questions that i need help with so if anyone can please help me out it whould be greatly appretiated.

question.1) this is the most improtant one, so in my game onnetworkspawn there are some gameobjects that i set active and some i set inactive via code but the problem is those gameobject when i run the rpc to turn them off it is not syncronized tp the other players and yes they all are attached to the main player object which has a networkobject component i tried to use server rpc and client rpc and even a network variable onvaluechanged, i also tried turing off the players sprite renderer the same way but its also not being syncronized notting works so if anyone knows some thing i dont please help.

question.2) my other question in my game after all the nessesary ammount of players are in a lobby the game automatically starts, so to put it simply i dont want to spawn the players imediately i want to wait sometime before the playes are spawned and make sure the time is all the same for all the players, basically if you have played call of deuty mobile the same way the multiplayer match begins in such a way that there if a player joins late the time will be the same and he dosent have to wait the ten second count down there is aster the players are spawned and the main game is about to begin just like codm.

question.3) i this is actually just another part of my first question some of the objects i turn off i add them to a lists and loop through them to turn them only one of them on after the player clicks on a button but event when i add them to the list it is also not being syncronized i tried using an rpc that also dosent work.

question.4) i also want to syncronize changing player sprites which a player can change when he dies and is about to be respawned he can choose a loadout and change sprites which the value of his/her current selected sprite is loaded from cloud save.

please if anyone can help me out with even one of these questions i whould greately appritiate it.

UnityJacob commented 1 year ago

Is your Log Level set to Developer on the Networkmanager? I've found that by default it is not and it contains some Non-error logs and warnings that help me navigate the setup of NGO stuff.

  1. By Attached, do you mean that these are Networkbehaviors that are children of the top-level NetworkObject? As far as I know this does not work with Instantiated Prefabs. More info Here

  2. The Game Lobby does this after the Ready Check (GameManager.BeginCountdown() : line 232). To support late. joiners coming in at the right time, you could have the countdown record the time it started, and when late joiners join they will get that time, and can have their UI update their countdown timing from the "official" start of the countdown.

  3. I'm not entirely sure if RPCs work on disabled gameobjects or behaviours. You might want to have the object that is controlling the list never disable itself, and control which objects are on/off.

  4. So a custom sprite that the player can upload? Changing loadouts would be done through regular RPC netcode systems. A custom sprite would have to come from a combination of the Unity Cloud Content Delivery and Cloud save services, where CCD stores the sprite, and Cloud Save would be responsible for associating that sprite with your player.

I hope some of this helps! If you have more general unity service and networking questions, you should join our networking discord server, where we have channels for many of these topics.

Feel free to follow up with questions here too!