- Home /
Reload a level while keeping in mind some var
Hi, I'm making a game where the player log in when he reach the main menu, I want my game to keep in mind the player name while I load a level, how can i do that ? I already checked this forum but i didn't understand the answer and how to do, can someone please help ?
Sorry for my bad english ^^
Hi there are alot of ways to do that,
You can keep a manager like object with command DontDestroyonload and keep your var on that object or
You can use playerprefs and save string at main menu than recall this string in your next scene playerprefs get string.
I didnt give any examples because im not fluent with js but there are many answers to use with playerprefs.
Hello, Like mkobaner said, - Create an empty object "GameData"; - Create an Script and put in the Object; - In the script use the DontDestroyOnLoad (this); - There you can put all the info that you want, - Ammo, Life, PlayerName .... etc.
Your answer
![](https://koobas.hobune.stream/wayback/20220612072600im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can you save variables one second ago and then use it to make an "if" statement? 3 Answers
Variables are resetting after loading the play scene 1 Answer
How to watch variables from another script efficiently? 1 Answer
Stamina script system 0 Answers
how to access variables in a function script attached to a clone 1 Answer