From dc20e8e87ef5c5ee420dd94cf35e6e9d806c6319 Mon Sep 17 00:00:00 2001 From: Fangh Date: Thu, 29 Feb 2024 22:06:16 +0100 Subject: [PATCH] fix(gamemanager): subscribe only after room is created --- Assets/Scripts/GameManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 8b081bb..38f383a 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -207,11 +207,12 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code) else { myOnlineRoom = realtimeDB.Child("rooms").Child(_code); - //subscribe to it - myOnlineRoom.ValueChanged += OnRoomUpdate; //if room exists, join it JoinRoom(() => { + //subscribe to it + myOnlineRoom.ValueChanged += OnRoomUpdate; + myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin; players.Add(currentPlayer);