Skip to content

Instantly share code, notes, and snippets.

@SocketWeaver
Created May 11, 2019 20:28
Show Gist options
  • Save SocketWeaver/1347d5ef42f44c0500271d3265c077bb to your computer and use it in GitHub Desktop.
Save SocketWeaver/1347d5ef42f44c0500271d3265c077bb to your computer and use it in GitHub Desktop.
GameSceneManager changes to handle the OnReady event of the SceneSpawner
public void OnSpawnerReady(bool finishedSceneSetup)
{
// scene has not been set up. spawn a car for the local player.
if (!finishedSceneSetup)
{
// assign different spawn point for the host player and the other players in the room
// This is okay for this tutorial as we only have 2 players in a room and we are not handling host migration.
// To properly assign spawn points, you should use GameDataManger or custom room data.
if (NetworkClient.Instance.IsHost)
{
NetworkClient.Instance.LastSpawner.SpawnForPlayer(0, 1);
}
else
{
NetworkClient.Instance.LastSpawner.SpawnForPlayer(0, 0);
}
// tells the SceneSpawner the local player has finished scene setup.
NetworkClient.Instance.LastSpawner.PlayerFinishedSceneSetup();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment