What's the best way to change scenes across all clients?
Hi guys!
As per the title, my application requires that all users be in a certain room at a certain time. I don't seem to be able to trigger this accross a second client (webXR build), only my local machine.
This is my SceneSyncModel:
On load, I locally set the nextScene string:
Then, once the realtime room has connected, I call SetNextScene(), which updates the model:
Then, when ready, I set the changing bool to true:
which then successfully fires a delegate:
This works locally, but doesn't seem to trigger the scene change on my other client.
Please let me know if you need any more info!
As per the title, my application requires that all users be in a certain room at a certain time. I don't seem to be able to trigger this accross a second client (webXR build), only my local machine.
This is my SceneSyncModel:
[RealtimeModel]
public partial class SceneSyncModel
{
[RealtimeProperty(1, true, true)]
private string _currentScene;
[RealtimeProperty(2, true, true)]
private string _nextScene;
[RealtimeProperty(3, true, true)]
private bool _isSceneChanging;
}
On load, I locally set the nextScene string:
public string nextScene;
void Awake()
{
nextScene = SceneManager.GetActiveScene().name == "Admin" ? "LobbyNetworkTest" : "Admin";
}
Then, once the realtime room has connected, I call SetNextScene(), which updates the model:
public void SetNextScene()
{
model.nextScene = nextScene; // local reference as above
}
Then, when ready, I set the changing bool to true:
public void SetIsSceneChanging(bool isChanging)
{
model.isSceneChanging = isChanging;
}
which then successfully fires a delegate:
private void IsSceneChangingDidChange(SceneSyncModel model, bool isChanging)
{
// if true, trigger scene switch
if (isChanging)
{
// Set bool to false so that on next scene load it is in the correct state
SetIsSceneChanging(false);
Debug.Log("IsChanging was true, switching to " + model.nextScene);
SceneManager.LoadScene(model.nextScene);
} else
{
Debug.Log("IsChanging was false, didn't switch");
}
}
This works locally, but doesn't seem to trigger the scene change on my other client.
Please let me know if you need any more info!