Time for action – saving the player's position
In a game with massive levels, the player may need to quit in the middle of a session. They could get frustrated if their position resets to the initial start zone instead of picking up where they left off; nobody wants to play the same part of the game twice just because they had to stop the first time:
Implement a system that saves the player's current location whenever they exit the game and respawns them at their saved location whenever the game is started again.
You can achieve this in the same way that you saved the number of coins, but keep in mind that the position data is stored as
Vector3
andPlayerPrefs
doesn't have aSetVector3
function.There isn't a single right way to go about saving data that's not natively supported by
PlayerPrefs
. Instead, it's all about how you want to implement the system and manipulate the data in a way that makes sense.Try saving each individual axis value as a floating-point number or an integer (using
SetFloat...