Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Creating Save Games in UDK

  1. #1
    Raven Knight
    Guest

    Question Creating Save Games in UDK

    Hi. I am trying to create a RPG using UDK, and there is one part I am having problems with. I need a way for the user to save their progress and then come back later. I have seen a method of creating save games using something called dll bind, but unfortunately while I am studying C++, I am still rather a C++ noob. Is this the only way to create save games from UDK? If it is (or even if it isn't) does anyone know of a really good tutorial that explains how the dll bind and C++ method works? I would not mind giving the time to learn this, but the couple tutorials I found just gave me a lot of C++ code without really explaining any of it. If this is the best method, I don't want to just copy someone else's code, I want to understand it. Any help would be greatly appreciated. Thank you.

    Raven

  2. #2
    Baldtoast
    Guest
    You can avoid C++ altogether and use BasicSaveObject()/BasicLoadObject() in Engine.uc:

    Code:
    /**
     * Serializes an object to a file (object pointers to non-always loaded objects are not supported)
     *
     * @param Obj The object to serialize
     * @param Pathname The path to the file to save
     * @param bIsSaveGame If TRUE, FILEWRITE_SaveGame will be used to create the file writer
     * @param Version A version number to save with the archive, so that we can safely fail when loading old versioned files
     *
     * @return TRUE if successful
     */
    native static final function bool BasicSaveObject(Object Obj, string Pathname, bool bIsSaveGame, int Version);
    
    /**
     * Loads an object from a file (saved with the BasicSaveObject function). It should already be
     * allocated just like the original object was allocated
     *
     * @param Obj The object to serialize
     * @param Pathname The path to the file to read and create the object from
     * @param bIsSaveGame If TRUE, FILEREAD_SaveGame will be used to create the file reader
     * @param Version A version number to match with the version saved in the archive, so that we can safely fail when loading old versioned files
     *
     * @return TRUE if successful
     */
    native static final function bool BasicLoadObject(Object Obj, string Pathname, bool bIsSaveGame, int Version);
    There's some documentation for it on the UnrealOnMobile page: http://udn.epicgames.com/Three/Unrea...veObject%28%29. Even though it's mentioned only on a mobile page, it works perfectly on the PC as well, giving you the added advantage of having a nice multiplatform way to save and load (and I'd presume that whenever Android and Mac OS X support comes out, these functions would work on them, whereas a DLL obviously won't). The default folder it saves to on the PC is the Binaries\Win32 folder, but you can specify an absolute path for Pathname.

    It's really simple to use, that bit of documentation is really all there is to it. The difficult part is deciding what you want to save, and what to do with the data you load in, but that's something that's really specific to you and your game.

  3. #3
    Raven Knight
    Guest
    Thanks, Baldtoast! I'll check that out. ^_^

  4. #4
    TheAgent
    Guest
    Ah a nicer and quicker way to save things. Just wondering where this can be placed? Should the code be used in GamInfo or it doesnt matter.

  5. #5
    Baldtoast
    Guest
    As far as I know it can be used anywhere, it's completely up to you where you want to call BasicSaveObject()/BasicLoadObject() from, or where to place the instance of the class you made to pass into them. A GameInfo subclass is a pretty logical place to put such an instance, in my opinion, assuming you intend for just the single player or server to use it. Personally I call BasicSaveObject()/BasicLoadObject() from inside my custom class that's to be saved/loaded, and just pass Self into each one.

  6. #6
    daimaku
    Guest
    Quote Originally Posted by Baldtoast View Post
    As far as I know it can be used anywhere, it's completely up to you where you want to call BasicSaveObject()/BasicLoadObject() from, or where to place the instance of the class you made to pass into them. A GameInfo subclass is a pretty logical place to put such an instance, in my opinion, assuming you intend for just the single player or server to use it. Personally I call BasicSaveObject()/BasicLoadObject() from inside my custom class that's to be saved/loaded, and just pass Self into each one.
    you have used it ? because i have readed that this function are for saving on udk mobile, can we used it in the udk too ?

  7. #7
    Baldtoast
    Guest
    Quote Originally Posted by daimaku View Post
    you have used it ? because i have readed that this function are for saving on udk mobile, can we used it in the udk too ?
    Yes, I use it with UDK for the PC and it works perfectly.

  8. #8
    daimaku
    Guest
    thanks for the info ....

  9. #9
    DanielH
    Guest
    I'm having a bit of trouble with the BasicSave and BasicLoad.

    What I did was create a class that only has a list of variables (for now 3 floats) and when I want to save I do something like this:

    Code:
    gameState = new class'DH_GameState';
    gameState.VOne = 10;
    gameState.VTwo = 10;
    gameState.VThree = 10;
    
    //Then I call this:
    class'Engine'.static.BasicSaveObject(gameState, "state.bin", true, 0);
    I load it in a similar way but the problem is it saves and loads 0s.
    I'm sure there is something that I don't understand. Can someone help point it out?

  10. #10
    Baldtoast
    Guest
    Can you post the exact code you use for saving and loading, and DH_GameState's code? Because I don't see anything wrong with that snippet that would cause it to not save or load those values.

    Also, you're not using the 'transient' modifier for those float variables (doing so would cause those values to not be saved or loaded), are you?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •