Re: Save System Question ;)
Posted: Thu May 19, 2022 3:59 am
This looks really nice... but seems to only work on stuff that is already in the scene... hellodear.in
teatv download
teatv download
Support and discussion forum for Pixel Crushers products
https://www.pixelcrushers.com:443/phpbb/
https://www.pixelcrushers.com:443/phpbb/viewtopic.php?t=5807
You can also set up savers to save data that's not in the scene, such as in ScriptableObject assets and non-GameObject classes. And by keeping the 'Save Across Scene Changes' checkbox ticked on a saver, the save system will retain that saver's data across scene changes (i.e., when the object isn't in the scene) so it can restore the state when it returns to the object's scene.
To expand on what Tony wrote, all you need to have is a SpawnedObjectManager on a gameobject in the scene (that has a list of the prefabs that are going to get instantiated/spawned that you want to keep saved), and those same prefabs (to be able to get added to the SpawnedObjectManager), will need to have "SpawnedObject" script on them
Code: Select all
public class PeristentObjectSpawner : MonoBehaviour
{
// CONFIG DATA
[Tooltip("This prefab will only be spawned once and persisted between " +
"scenes.")]
[SerializeField] GameObject persistentObjectPrefab = null;
// PRIVATE STATE
static bool hasSpawned = false;
// PRIVATE
private void Awake() {
if (hasSpawned) return;
SpawnPersistentObjects();
hasSpawned = true;
}
private void SpawnPersistentObjects()
{
GameObject persistentObject = Instantiate(persistentObjectPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
DontDestroyOnLoad(persistentObject);
}
}
Does the saved position look correct in the save data? If so, you could temporarily add a Debug.Log to the PositionSaver method that sets the player's position. Then add similar Debug.Logs to any of your own initialization code that moves the player. Maybe the order isn't what you intend.HawkX wrote: ↑Thu Jun 09, 2022 1:21 pmI just checked the save file (which i do not encrypt for now so its easier to debug/test)
this is the only one that edits any kind of "position" on the main prefab
...
"key": "CharPositionSaver",
"sceneIndex": -1,
"data": "{\n \"positions\": [\n {\n \"scene\": 0,\n \"position\": {\n \"x\": 21.2435302734375,\n \"y\": -6.889900207519531,\n \"z\": 66.82514190673828\n },\n \"rotation\": {\n \"x\": 0.0,\n \"y\": 0.8612263202667236,\n \"z\": 0.0,\n \"w\": 0.5082217454910278\n }\n }\n ]\n}"
If you tick the Multiscene checkbox, it will save the player's last position in every scene that the player leaves. In most games, this isn't relevant because you're either saving your game in a single position, or you're changing scenes using spawnpoints.
That suggests that maybe you have a coroutine or something similar that updates the player position after the PositionSaver moves the player.
It only fades when changing scenes or loading a saved game. But you can use a FadeIn() sequencer command to fade in on play like DemoScene1 if you want to do that. The easiest ways to set up the Standard Scene Transition Manager are to copy the setup on DemoScene1's Dialogue Manager, or download the SaveSystem prefabs from the Dialogue System Extras page.HawkX wrote: ↑Thu Jun 09, 2022 1:21 pmI 100% agree about the "Standard Scene Transition Manager"... I have been thinking about it for a while...
I know you got something like that in your amazing system...
do you have any documentation link on how to properly set-it-up?
while i did make one in my scenemanager when transitioning scenes, it doesnt do any fade "on start" when i load for the first time... and its assuredly much less "well made" than whatever you did