|
I am trying to use playerprefs to save the main character's position. I already was able to save an integer and then load it. I tried multiple ways using playerprefs to save a character's position, but apparently, those ways used too much data with playerprefs, because Unity crashed. Unity worked again after i removed the playerprefs from the scripts. Does anyone know how to save a players position without overloading unity?
(comments are locked)
|
|
Saving a few floats won't come anywhere near overloading Unity; something is wrong with the code you wrote. You save the position by writing the x, y, and z coords of the player using PlayerPrefs.SetFloat. If you want to make it a little simpler, you can use ArrayPrefs, which would let you write
Assuming
(comments are locked)
|
|
On some platforms (especially Android and iOS) it can be really slow to save a lot of data in PlayerPrefs. Sometimes it can take multiple seconds, giving the impression that Unity crashed. This could be the case if you're saving a lot more than just the player position. A solution is to write a custom PlayerPrefs class where the data is only saved periodically to a file. We've shared our own PlayerPrefs class for anyone to download: http://www.previewlabs.com/writing-playerprefs-fast/
(comments are locked)
|
|
here is a working script
(comments are locked)
|
