Loading PlayerPrefs for characters after selecting level, not when button for PlayerPref clicked on

I managed to load my players by pressing the relevant character buttons and then loading up the first level.

What I wish to achieve is when the player clicks on the character buttons, it takes them to the Level selection screen and when the button for one of those levels is pressed, the game loads up the level as well as the previously chosen character.

Any suggestions would be much appreciated.

If I understand correctly what you’re asking, I think your concern is how to get data from one scene to another (like the selected character).

The easiest way to do that is with a static variable. Another way is with a GameObject on which you’ve called DontDestroyOnLoad.

HTH,

  • Joe
1 Like

Oops I said level twice at the end, I do apologize, it is corrected now. I will look into them. I did see the DontDestroyOnLoad function, so I will play around with that. Thanks!

Actually, I do need to check what button the player pressed on the previous menu, so I need some type of function to check that - I am guessing, because no matter what level I go into, the game will not be able to tell what happened on the other menu (scene). Any suggestions? I am not really programming-literate so I am learning as I go, so I do appreciate the help.

Yes — that’s what I was talking about in my previous post. The value of the button pressed must be stored in either a static variable, or in a game object on which DontDestroyOnLoad was called. Then (either way), it will still be there for you to check in the next scene.

1 Like