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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

How to save player data on a server

Discussion in 'Multiplayer' started by Chefix, Mar 6, 2023.

  1. Chefix


    Mar 14, 2017

    I wanted to ask how should I be saving player data like inventory, position, stats, etc. on a server.

    Let's assume a scenario where the player is playing the game, and he picks up an item off the ground and now it should be added to his inventory. How am I supposed to update the server to add this item to the player's inventory?

    The only way I know of to implement this system is a RESTful POST request to the server once an item needs to be added to the player's inventory that is saved in a database.

    But if the game revloves around constantly picking up items, then the server would be bombarded with POST requests constantly.

    Is there a better way to hold a player's data on a server in real time?
  2. CodeSmile


    Apr 10, 2014
    Yes, any realtime networking library such as Netcode for GameObjects, Fish-Networking, Mirror, Photon, ... supports synchronizing variables via UDP messages. POST isn't suitable for realtime games. It can be used to persist a player's state to a database after each level (for example) or whenever the flow of the game is slowed or interrupted, eg user entering a shop, dungeon or similar.