As the title says, after hitting the load button, the player won’t go back to the transform variables i have set. Yet all my other variables loading in work fine. (using a binary formatter)
here’s the code:
a piece of my save and load script.
public void SavePlayerData()
{
SaveSystem.SavePlayer(this);
Debug.Log("Saved Game");
}
public void LoadPlayerData()
{
PlayerData data = SaveSystem.LoadPlayer();
Vector3 loadedPosition;
loadedPosition.x = data.playerTransform[0];
Debug.Log(loadedPosition.x + " x position loaded");
loadedPosition.y = data.playerTransform[1];
Debug.Log(loadedPosition.y + " y position loaded");
loadedPosition.z = data.playerTransform[2];
Debug.Log(loadedPosition.z + " z position loaded");
transform.position = loadedPosition;
}
all the parts of my playerdata class requiring transform stuff
[System.Serializable]
public class PlayerData
{
public float[] playerTransform = new float[3];
public PlayerData(Player player)
{
playerTransform[0] = player.transform.position.x;
playerTransform[1] = player.transform.position.y;
playerTransform[2] = player.transform.position.z;
}
all the values are being saved and are showing in the debug.log statments like they should