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

Is database needed for 2D games?

Discussion in 'Editor & General Support' started by Yunho0320, Oct 1, 2015.

  1. Yunho0320

    Yunho0320

    Joined:
    May 16, 2015
    Posts:
    11
    Hi, I recently found interest in making 2D games and I was wondering how important database is.
    I want to make simple 2D games like Mr.Jump and Crossy Road.
    And when we play the game, our best score and new characters get saved in our phone.
    Is that something to do with database?
    If so, can you recommend me a language to study and approximate depth I have to reach in that language?
     
  2. seldom

    seldom

    Joined:
    Dec 4, 2013
    Posts:
    118
    There is no need to use a database for saving such stats, you can simply store them in files. That is what Application.persistentDataPath is for.
     
    Yunho0320 likes this.
  3. Yunho0320

    Yunho0320

    Joined:
    May 16, 2015
    Posts:
    11
    Does it mean that characters and best records etc are saved to individual user's phone and Application.persistentDataPath enables this?
    I haven't studies it yet, so can you tell me what it is? Is it just a code?
     
  4. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Perhaps Seldom isn't on the same page as you, yes you can store things locally, but if you want them globally (like players from around the world put their ranks). Then, yes you will need some sort of database where players can connect too. Not sure if Android and Iphone have built in functions for any of this(like through their business - create leader boards for you), but however that may be, you can always set your own up.

    I haven't ever done it yet, but somebody could correct me about this, but I believe you'll need to use the WWW Class inside Unity. Just go to google and type in Unity WWW Class and it will pop up somewhere.
     
    Yunho0320 likes this.
  5. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    It depends if earning characters, rewards, and achievements is something that you want to share on a game social leaderboard between many players or just locally for that device. The entire dB would reside on a server designed to handle such a game.
     
    Yunho0320 and N1warhead like this.
  6. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    You'll use a database for accounts, leaderboards, and basically anything that requires other people to see your information or information that can't shouldnt stored locally (accounts and scores if the game is using leaderboards). Its rather simple to change databases from unity and requires you to know very basic php. From unity using the WWW class and WWWForm class you can send a request to "run" your php script and the php script will then do whatever you program it to do. It can insert new data into your table, update data, delete data, anything. Go look up some tutorials on php and mysql on w3schools (great resource I use it all the time). I wish you luck!