Skip to content

Commit

Permalink
Fixed Scene Transition Delay (Clients)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dani-24 committed Jul 8, 2024
1 parent faea27b commit 5c266f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public void OpenGear()

public void StartGame(string scene)
{
UI_Manager.Instance.PopUp_LogMessage("Starting Battle", 1, true, scene);
UI_Manager.Instance.PopUp_LogMessage("Starting Battle", 0.5f, true, scene);
ConnectionManager.Instance.activeSceneName = scene;
SceneManagerScript.Instance.TeamsForBattle();
}

Expand Down
15 changes: 6 additions & 9 deletions MultiplayerGame/Assets/Scripts/Managers/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ public class ConnectionManager : MonoBehaviour
public bool disconnect = false;

bool changeScene;
string sceneToChange;

#region NET Data

[Header("NET Data Display")]
[SerializeField] bool connectionStablished = false;
string activeSceneName;
public string activeSceneName;

public int ownPlayerNetID = -1;
public PlayerPackage ownPlayerPck;
Expand Down Expand Up @@ -240,7 +239,7 @@ void ReadPackage(Package pck)
// CHANGE SCENE
if (!isHosting && pck.currentScene != activeSceneName)
{
sceneToChange = pck.currentScene;
activeSceneName = pck.currentScene;
changeScene = true;
}

Expand Down Expand Up @@ -358,8 +357,7 @@ private void Awake()

public void StartConnection()
{
if (isConnected)
EndConnection();
if (isConnected) EndConnection();

try
{
Expand Down Expand Up @@ -780,6 +778,8 @@ void Start()
if (connectAtStart) StartConnection();

audioSource = GetComponent<AudioSource>();

activeSceneName = SceneManager.GetActiveScene().name;
}

void Update()
Expand Down Expand Up @@ -808,8 +808,6 @@ void Update()

userName = UI_Manager.Instance.userName; // this should only update when the username is updated instead of every frame

activeSceneName = SceneManager.GetActiveScene().name;

delay += Time.deltaTime;

UpdateGameObjects();
Expand All @@ -818,8 +816,7 @@ void Update()
{
changeScene = false;
SceneManagerScript.Instance.netGOs.Clear();
SceneManagerScript.Instance.ChangeScene(sceneToChange);
sceneToChange = "";
SceneManagerScript.Instance.ChangeScene(activeSceneName);
}

if (activeSceneName != lobbyScene) connGameplayState = ConnectionGameplayState.Playing; else connGameplayState = ConnectionGameplayState.Lobby;
Expand Down
6 changes: 5 additions & 1 deletion MultiplayerGame/Assets/Scripts/Managers/GameManagerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ void Update()
}
}

if (!timerNetGo.connectedToServer && timerCount <= 0) SceneManagerScript.Instance.ChangeScene("000_Lobby", true);
if (!timerNetGo.connectedToServer && timerCount <= 0)
{
SceneManagerScript.Instance.ChangeScene("000_Lobby", true);
ConnectionManager.Instance.activeSceneName = "000_Lobby";
}

break;
}
Expand Down
2 changes: 1 addition & 1 deletion MultiplayerGame/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 1.0.0
bundleVersion: 1.0.1
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 5c266f5

Please sign in to comment.