Saving Player Rotation

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
denv0r
Posts: 1
Joined: Wed May 09, 2018 8:23 pm

Saving Player Rotation

Post by denv0r »

Hi, I would like to save my player's rotation as well as it's position. I assumed that the following code would do that but it doesn't seem to be working. Any ideas?

Code: Select all

public void Save()
{
	//ES2.Save(InventoryController.Instance.playerItems, "inventory");
	ES2.Save(SceneManager.GetActiveScene().name, "savedScene");
	ES2.Save(player.transform.position,"playerPosition");
	ES2.Save(player.transform.rotation, "playerRotation");
	Debug.Log("saving");
}

public void Load()
{
	player.transform.position = ES2.Load<Vector3>("playerPosition");
	player.transform.rotation = ES2.Load<Quaternion>("playerRotation");
	Debug.Log("loading");
}
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Player Rotation

Post by Joel »

Hi there,

I've not seen this before, and saving rotation appears to be working fine at my end. Would you be able to send me a complete script which replicates this, so I can see how your Save() and Load() methods are being called?

Also note that if your object is nested, you may need to save localPosition and localRotation rather than the global position/rotation.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked