x


What are the basics of saving and loading game?

I know that saving a game is dependant on the game and it's content so there is no simple answer t this, but i can't seem to find a good explaination of how to do it...

i believe there are two ways to go about it, XML and Player Prefs or something? Can some1 please give me an explaination of either?

e.g

function SaveGame(){

what do i type here?So (HERE) i can enter the save game destination?;

& What do i say so that (this) is the data i save?;

}

more ▼

asked Feb 05 '11 at 03:43 PM

Mike Ledwards gravatar image

Mike Ledwards
212 26 29 38

http://answers.unity3d.com/questions/971/how-to-scrip-a-save-load-game-option

Here is enough stuff for starting. Also there is a lot about exporting arrays to XML in Adobe ActionScript 3 reference. You can write a few scripts in Flex Builder(As I was doing at first time, because I started FlexBuilder much earlier than Unity). There is a free version of FB by the way.

Feb 08 '11 at 01:15 PM Simple
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Basics are:

  • Saving

    1.Decide what exact information u want to save

    2.Make a script that gathers this information in data array

    3.Make save menu(and pause game)

    4.Save this data array as txt file(for starting) on "Save button pressed". Better use binary files.

    5.Return to game.

  • Loading

    Make loading menu and loading screen.

    1. Let player choose which file to load
    2. Open your save file for input.
    3. Make a script that inputs data from your file to data array. Then it accepts specific data to specific
      objects on your scene. Of course you need to instantiate mostly all scene with all objects with properties from data array.
    4. Start game on loaded scene.

It is rather big code and it depends on what you want to save. You can read about import/export and files in reference documentation.

more ▼

answered Feb 05 '11 at 04:32 PM

Simple gravatar image

Simple
485 2 2 13

good answer, thanx for the response. i understand what i want to save... things like players name, level, stats and inv items but what i need to know is how to script the filepath for a savefile. I have traulled through the documents for the past week and can't find what i'm lookin for.

Feb 08 '11 at 11:58 AM Mike Ledwards

Application.dataPath Contains the path to the game data folder. More info: http://docs.unity3d.com/Documentation/ScriptReference/Application-dataPath.html

Aug 20 '12 at 12:51 PM chelnok
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x824
x455
x442
x155

asked: Feb 05 '11 at 03:43 PM

Seen: 1764 times

Last Updated: Aug 20 '12 at 12:51 PM