i’m going mad trying to get this to work and i know i’m doing something really dumb, probably the strings but i just can’t find it. Can anyone put me out of misery?
i’ve confirmed that the array pointer is correct but i’m getting ‘1’ back for all float values. I don’t think this is even the default.
this is part of my save game state code:
function OnApplicationQuit ()
{
var n = 1;
for (var piece in pieces)
{
var pieceName = "P" + n.ToString ();
valueName = pieceName + "posX";
PlayerPrefs.SetFloat("valueName", piece.transform.position.x);
valueName = pieceName + "posY";
PlayerPrefs.SetFloat("valueName", piece.transform.position.y);
valueName = pieceName + "posZ";
PlayerPrefs.SetFloat("valueName", piece.transform.position.z);
valueName = pieceName + "rotX";
PlayerPrefs.SetFloat("valueName", piece.transform.eulerAngles.x);
valueName = pieceName + "rotY";
PlayerPrefs.SetFloat("valueName", piece.transform.eulerAngles.y);
valueName = pieceName + "rotZ";
PlayerPrefs.SetFloat("valueName", piece.transform.eulerAngles.z);
n++;
}
}
and this to restore:
function Restore ()
{
var n = 1;
for (var piece in pieces)
{
var pieceName = "P" + n.ToString ();
valueName = pieceName + "posX";
piece.transform.position.x = PlayerPrefs.GetFloat("valueName");
valueName = pieceName + "posY";
piece.transform.position.y = PlayerPrefs.GetFloat("valueName");
valueName = pieceName + "posZ";
piece.transform.position.z = PlayerPrefs.GetFloat("valueName");
valueName = pieceName + "rotX";
piece.transform.eulerAngles.x = PlayerPrefs.GetFloat("valueName");
valueName = pieceName + "rotY";
piece.transform.eulerAngles.y = PlayerPrefs.GetFloat("valueName");
valueName = pieceName + "rotZ";
piece.transform.eulerAngles.z = PlayerPrefs.GetFloat("valueName");
n++;
}
}