Cant save the position of a GameObject
Posted: Sat Apr 10, 2021 10:24 pm
Hey, Im trying to save the position of my Player Gameobject and I have created two simple save and load methods that execute on button press for that.
public GameObject player;
public void Save ()
{
ES3.Save<Vector3>("playerPosition", player.transform.localPosition);
}
public void Load()
{
player.transform.localPosition = ES3.Load<Vector3>("playerPosition");
}
But for some reason this is not working at all. Sometimes just nothing happens and sometimes I get an error saying the key playerPosition does not exist but the player never acctually changes its location.
Thanks in advance!
public GameObject player;
public void Save ()
{
ES3.Save<Vector3>("playerPosition", player.transform.localPosition);
}
public void Load()
{
player.transform.localPosition = ES3.Load<Vector3>("playerPosition");
}
But for some reason this is not working at all. Sometimes just nothing happens and sometimes I get an error saying the key playerPosition does not exist but the player never acctually changes its location.
Thanks in advance!