- Home /
playerprefs problem
I am making a relatively simple game, but i want to know how to save it. I made it using quite a few scripts and i ave two scenes: main menu and the actual game. I want to save the players position and some variables and then be able to have the option to either load them, or make a new file. It would be nice to be able to save up to three or so files. I heard about playerprefs and learned some stuff about it, but i could only find stuff about highscores.
I tried the playerprefs.getint in a script, it didn't work. here's the script i tried it on, before i put in the playerprefs script. It's supposed to respawn an enemy a certain number of times and then stopped. I just wanted, for now, to save how many times it respawned an enemy:
var Beholder : Transform; var targetThing : Transform; var Weapon: Transform; beholder.thing = targetThing; beholder.weapon = Weapon; var deathTimer : int = 0; var maxRespawns : int;
var respawnCount : int = 0.0;
function Update () {
if(beholder.death) {
deathTimer++;
if(deathTimer == 50 && respawnCount < maxRespawns)
{
deathTimer = 0;
respawnCount++;
beholder.death = false;
var newBeholder = Instantiate(Beholder, transform.position, transform.rotation);
}
}
}
p.s. I have a pc so i use UniSciTE
I wouldnt use playerprefs, but serialization. Look it up, I cannot help you with javascript serialization.
Your answer
Follow this Question
Related Questions
player prefs, problem but no problem??? 1 Answer
Save/load playerprefs 2 Answers
Saving and Loading data in one scene 1 Answer
Null Reference Exception even after check 1 Answer
Save and Load Function 2 Answers