- Home /
PlayerPrefs for FPS?
I really don't know how to save my game progress on a FPS game. Example: If I press the "save" button then it should save what gun I'm currently holding and magazine etc, health and position. And also load the game from what I saved. Is it possible? If so, please tell me how! I've been googling around but no answers :(
Answer by jorashwil · Mar 09, 2013 at 07:46 PM
PlayerPrefs.SetString(//insert any information you want saved)
My PlayerPrefs looks like this:
void SaveCharacterData(){
GameObject pc = GameObject.Find ("pc");
PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
PlayerPrefs.SetString("PlayerName", pcClass.Name);
}
as of right now anyway. Everytime you add something that needs to be saved (i.e. Inventory, equipment, etc) you have to add it to the string along with the location of where to find the reference.
Thank you! But not to ask much, can you please write it in Java 'cos I wrote the scripts in Java and C# can't get the components, I suppose?
I'm not sure about JS, I use C#, so here are a few URL's that should help:
JS = http://wiki.unity3d.com/index.php?title=ArrayPrefs2#JavaScript_-_PlayerPrefsX.js
Unity Ref = http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
Sorry for late reply, but I've been on a trip.
Thank you! After reading those documentations and tried some examples myself. I then got it to work! Thanks a lot! :-)
Your answer
Follow this Question
Related Questions
Set int to object from list? 0 Answers
Saving character selection 1 Answer
Saving boolean values using PlayerPrefs 1 Answer
How do I save and load the state of the GameObjects with PlayerPrefs? 0 Answers
Save/Load Variable with playerprefs 1 Answer