How do I save a charcater Selection?
Hello,
I am working on a 2D game that is going to released on Android. I am currently working on a character selection system and I have everything in place but I am trying to add a system where if the player selects a character that selection will save even when the scene is reloaded. Right now when the scene is reloaded the character goes back to the defalut character and I want it to save to the last selection.
Here is the code that runs when the player selects a character
public void YellowPlaneSelect()
{
if (TheScore.thePoints >= yellowPlaneCost && yellowPlaneSave == 0)
{
Destroy(currentPlayer);
GameObject newPlayer = Instantiate(yellowPlane);
yellowPlaneSave = 1;
PlayerPrefs.SetInt("yellowPlaneSave", yellowPlaneSave);
PlayerPrefs.SetString("yellowPlaneText", Select);
TheScore.thePoints -= yellowPlaneCost;
PlayerPrefs.SetInt("Money", TheScore.thePoints);
newPlayer.GetComponent<movemnt>().enabled = false;
newPlayer = currentPlayer;
characterSelect.SetActive(false);
}
else if (yellowPlaneSave == 1)
{
Destroy(currentPlayer);
GameObject newPlayer = Instantiate(yellowPlane);
newPlayer.GetComponent<movemnt>().enabled = false;
newPlayer = currentPlayer;
characterSelect.SetActive(false);
}
else if (TheScore.thePoints < yellowPlaneCost && yellowPlaneSave == 0)
{
Debug.Log("Not enough coins");
}
}
Basically I need a way to save the currentPlayer gameObject variableeven when the scene is reloaded.
If anybody has any suggestions that would be great
Thanks!
Comment
Your answer