Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to connect a database to a game?

Discussion in 'Scripting' started by Deleted User, Oct 20, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hello everyone,

    I am trying to make a game where players can create accounts and save their progress on a database. I have many questions about the concept.

    - I think I need a server and then I need to create a database on the server (by using MySQL). How can I send a message to the database from the game? (For example, creating an account. Account name and password)

    - I need to return random numbers to decide if an action/event is success or fail in the game. To prevent players from cheating, I need to generate random numbers on the server. How can I return a random number from the server and execute that number in the game?

    - Do you have any suggestions for what kind of server service I need to make a game like this?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    You would probably create a web server that communicates with a database, and then connect your Unity client to the server on the web. You probably don't want to have your database login credentials etc. in the client.

    You can google for Unity and MySQL and you will get a few links and practical guides / discussions.
     
  3. Deleted User

    Deleted User

    Guest

    Thank you for the answer. I'll check it.

    I was thinking of taking username and password from the client and send it to the database to create a new data.