Save Transform and other Information into Binary File
Hello everyone,
I need some help with something, I am quite new to the saving system but I used this tutorial to create a Save-Load system between scenes.
It works fine, it loads the information I want such as Health, Points and so on, and the UI properly updates because it's directly linked to those values.
To clearly explain, I transition through a door, and when I transition back, I am back at the original spawn point, even though I have a spawn point right before the door. When the player hits that spawn point, it is properly assigned.
However I lose that information when I transition to the other scene, because I don't know how to store a Transform with that script. How do I save that spawn point into the file?
public void Save() { BinaryFormatter bf = new BinaryFormatter (); FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat");
PlayerData data = new PlayerData ();
MutagenControlScript dataMutagens = new MutagenControlScript ();
//save health and hunger
data.Health = Player.GetComponent<PlayerDataModel>().PlayerHealth;
data.Hunger = Player.GetComponent<PlayerDataModel>().PlayerHunger;
bf.Serialize (file, data);
file.Close ();
}
[Serializable] class PlayerData { public float Hunger; public float Health; public float Experience; public float Level; public float SkillPoints; }
Thank you .
Gonçalo P.