- Home /
Why won't my Player load with the correct position and rotation on my android device, but it will on my computer?
So I'm having a problem with the loading of my players position and rotation. I'm using player prefs to save the information as floats. I can Debug.Log() the values and it shows up just fine. However when i build the game out, it does not work... It just send me back to the beginning of the level with 0 rotation as it should when a new game is started. What is happening and how can I fix it?
Here's some snippets of code to help you guys understand what is going on.
Keep in mind none of this has actual variables, it's just for the idea.
// saving the value(each value for position is saved as individual "X" "Y" and "Z"
PlayerPrefs.SetFloat(name, value);
// when loading game, making variable equal to value
variable = PlayerPrefs.SetFloat(name, value);
// Setting players position to the value
player.transform.position.x = variable;
// for rotation
player.transform.eulerAngles.y = variable;
Answer by OWiz · Feb 07, 2013 at 02:49 AM
When you push a new build out to your Android, it deletes whatever old PlayerPrefs you have in there. If you'd play around on the android device, save it, and then load it up, you'd probably find that it loads correctly.
Or if it doesn't load at all, then it might not correctly save or load playerprefs, perhaps because you have the location hard-coded to a point on your computer, which your Android obviously cannot find.
Ok so here's the strange part, some of the other player prefs ARE saving so it really doesn't make any sense as to why these are not. I will give the entire code when I get home, but if you have any other suggestions, that would be great :)
Your answer
Follow this Question
Related Questions
How to save players rotation in Unity? PlayerPrefs 3 Answers
Flip over an object (smooth transition) 3 Answers
Character rotating to previous rotation 1 Answer
Having difficulty with Parent Object rotation and Child Object movement. 0 Answers
Rotating gameObjects gives me completely inaccurate values at runtime 1 Answer