Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Help with saving data

Discussion in 'Multiplayer' started by xIvan95, Mar 26, 2014.

  1. xIvan95

    xIvan95

    Joined:
    Feb 24, 2014
    Posts:
    10
    Hi! I am new to Networking in Unity and I want to know something that I might already know.

    I want to know how I can save data on the network, I mean, I want to store all the data about the player, so when he disconnects it will be saved, and when he connects he will get that data and will be able to keep playing the game.

    I know that big games such as WoW, Rift, and all that, uses SQL databases connected to the server, but I want my game to be small, so I want my own "database" inside Unity.

    - How can I do that?
    - Is it the same as saving offline? (Playerprefs, xml, etc)
     
  2. unityuser1324235141

    unityuser1324235141

    Joined:
    Apr 5, 2013
    Posts:
    44
    It's pretty much the same as saving offline. If your game is going to be hosted by its' players, saving into xml etc will be fine. For a small game, the server application would write any persistent data (items in players inventory etc) into your database whenever it changed. You could use XML for this, just be aware that it won't perform to anywhere near MMO standards although it should suit your needs.
     
    Last edited: Mar 26, 2014
  3. xIvan95

    xIvan95

    Joined:
    Feb 24, 2014
    Posts:
    10
    So using XML files, do I have to include it only in the Server build or also in the Client build? :D thanks for the help!

    (I am using 2 builds, one for server and one for client)
     
  4. unityuser1324235141

    unityuser1324235141

    Joined:
    Apr 5, 2013
    Posts:
    44
    Only the server needs to keep this information. The server keeps information like accounts, player positions and character levels etc. Clients should never have direct access to this information - the server should only give them what they need when they need it. For example, when a player logs into the server, the server would access the database to find out what this player's position was before he left the server and what items he had. The server would then send information to the client saying "move to this position. you have these items.". If the clients stored this information, they could easily cheat and spawn whatever they wanted.