hello, ive been stumped on this problem. I need to save this object (some kind of Highscore Line) where when the player dies. it leaves an object(Highscore Line) and so when i restart the game or unpause and play it again the instanitated object(Highscore Line) would be still there?
Instantiate(HighScoreLine,new Vector3(Player.position.x,0,0),Quaternion.identity);
There are multiple options.
The easiest would be to save each death to a file on your pc and when you start your game you read that file and instantiate objects with that information.
A little more complex solution would be to setup a database and save deaths into it and loading from it at the start of the game again. This solution would make sense if you want the deaths of all your players to be visible to all players.
However you do it the principle will be the same. You save your data somewhere in someway and load it at game start.
I have an idea, you can save an integer(PlayerPrefs) and when you die and you are above high score
if(dead && score > highScore){
//Save the integer with playerprefs
}
and then every time you start the game you can instantiate using the integer you saved.
You might have some problems since the integer value isn’t like x value but thats a nice start to the code.