Hello,
First, I love the asset. Whenever there is a feature I am looking for, this thing has it. I love it!
Is there a reason LoadAdditiveScene doesn't support player spawnpoint?
My "Start" scene contains just Main Menu and the basic Load game functionalities.
My main scene, "Persistent", contains the Player model, camera, global lightning, game managers, the usual. This scene is always there and everything is loaded additively.
Scenario #1: I have "Persistent" scene loaded and 1 additive scene, "City", loaded. I walk to a door which is a trigger for scene change to "House". I guess normally I could call "LoadScene("House", "SpawnInsideHouse"), but cannot because It would unload my other scenes. I call "LoadAdditiveScene("House").
I guess I have to relocate my player with my own script, which is no big deal, but made me wonder if I am missing something here?
Thanks in advance!
Load additive scene with spawning
Re: Load additive scene with spawning
Hi,
With SaveSystem.LoadAdditiveScene(), we don't know whether you're loading a new location for the player to be in (e.g., "House") or just streaming in more of the world for the player to continue moving through (in which case you don't want to move the player).
If you're additively loading "House", I recommend registering a method with SaveSystem.sceneLoaded. In this method, manually call the player's PositionSaver.ApplyData(). For example:
With SaveSystem.LoadAdditiveScene(), we don't know whether you're loading a new location for the player to be in (e.g., "House") or just streaming in more of the world for the player to continue moving through (in which case you don't want to move the player).
If you're additively loading "House", I recommend registering a method with SaveSystem.sceneLoaded. In this method, manually call the player's PositionSaver.ApplyData(). For example:
Code: Select all
SaveSystem.sceneLoaded += OnSceneLoaded;
...
void OnSceneLoaded(string sceneName, int sceneIndex) // This example assumes script is on the player.
{
SaveSystem.sceneLoaded -= OnSceneLoaded;
var positionSaver = GetComponent<PositionSaver>();
positionSaver.ApplyData(SaveSystem.currentSavedGameData.GetData(positionSaver.key));
}
Re: Load additive scene with spawning
Oh I see, thank you for a quick reply!
I am actually planning on loading scenes additively for "world streaming" purposes, so that makes sense.
I guess I am just wondering what's the ideal way to approach this without having to constantly unload/load my open areas when entering a building and without making things too complex.
I am actually planning on loading scenes additively for "world streaming" purposes, so that makes sense.
I guess I am just wondering what's the ideal way to approach this without having to constantly unload/load my open areas when entering a building and without making things too complex.
Re: Load additive scene with spawning
In the method in which you load the new location and set a spawnpoint, you can use the code above to ensure that the player's PositionSaver moves the player to that spawnpoint.