Search Unity

Best database for a Unity3D PC game

Discussion in 'Multiplayer' started by Fakhiha25, May 24, 2023.

  1. Fakhiha25

    Fakhiha25

    Joined:
    Jan 21, 2023
    Posts:
    2
    I am creating a VR game in Unity, it will be a PC game. I want to store user login info, score, checkpoints, learning points, rewards etc in the database. I checked out firebase but it doesnt work for pc games apparently.
    I only have Oculus Rift to test my game else I wouldve switched to android as which platform the end game is for doesn't really matter. What are some other good alternatives? What should I use for my pc game?
    I will later use the score and rewards to create learning points which will then be processed in an ML model to perform categorization.
    Moreover, it is possible that I integrate firebase with unity while keeping my game in Windows platform while I test it on Rift and in the end I build it for android so it works fine with firebase?

    TIA!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    Define „best“. Given your requirements, ANY database will work just fine.

    The golden rule of code architecture demands that you write an interface that all database access methods pass through. A data storage factory creates an implementation of the actual database based on requirements such as platform. Now all you need to do is write an implementation of that interface for every database you want to store data to. You can start by using SQLite which only works offline but should be okay for now and for dev. Then implement another for Firebase and have that instantiated only when running on mobile devices. And a third (MySQl perhaps) for desktop.

    The „best“ solution is really to write the code so that it simply doesn‘t matter which database the code is using at any time.

    PS: It seems obvious but keep in mind that a user will not be able to take the mobile login/account to desktop unless you have some backend tech that synchronizes the databases. So you may want to choose a solution that works for all platforms. But the point is that you don‘t want to make that decision now. Push it back as far as possible by using the simplest solution for development (sqlite) and only late in the project add support for other databases.
     
  3. Fakhiha25

    Fakhiha25

    Joined:
    Jan 21, 2023
    Posts:
    2
    Thankyou so much for your feedback. Since my game is not multiplayer, and it is primarily for PC (as I only have access to Oculus Rift for testing) should I just go with SQLite all the way? The game is my final year project for college and does not need to be published commericially, so if I just go with sqlite that should be fine right?
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    Should work fine if it's not an issue for you that the SQLite database will be stored locally on the device. Meaning SQLite will be a file that's created upon first installing/running the app in the platform-specific location for user files (so it can be written to). On Windows that would be somewhere under AppData and the exact folder is determined by Project Settings => Player >> Company/Product Name (details are somewhere in the Unity manual).