Search Unity

Online maps, with users, ratings etc.. what tools to use?

Discussion in 'Multiplayer' started by CurlewStudios, Feb 16, 2019.

  1. CurlewStudios

    CurlewStudios

    Joined:
    May 22, 2016
    Posts:
    9
    Hi! I am trying to figure out how to structure the online component of my game but I'm completely new to network programming, servers, and databases.

    The core of what I want to do is for the user to upload maps they have created in the in-game editor to a server. Users can browse maps made by other players and sort them by highest rated, author, date uploaded etc.
    They can also download, play and rate these maps.

    From what I can gather, at least this metadata should be very easy to handle in a SQL database, but I would guess the map data itself shouldn't be kept in this database?
    The maps are just XML files with a tile system and some other things. How would you go about storing these maps? And how would you handle the communication? Are there any built-in unity tools that could help me in this? Oh and any recommendations for server hosting? I wouldn't expect any more than 20 users accessing it at the same time.

    Thank you for any pointers you can give me on how to approach this!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If there is actually no multiplayer aspect to the game, I'd consider doing this all with UnityWebRequest on the client side, and PHP/MySQL on the server side. I'd store the files as regular files on disk on the server, and have the PHP scripts assign file names to them. You'll need to aggressively enforce validation of the file types and sizes that people upload by the way, or you risk users uploading really anything.

    As far as hosting itself, shop around for either web hosting solutions with MySQL included, or consider renting a VPS (you'll have to do more management of a VPS, which is basically a "virtual machine", but you'll have more control over it). Unless you're dealing with some unusually large XML files, you can probably get away with some very cost effective hosting packages for this kind of thing. Maybe in the $5-$15 per month range. Cheap enough that you should be able to just try a few providers out rather than guess how they perform.
     
  3. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    I've built a level editor before with server side storage and I would suggest using a database for your XML maps, rather than files as @Joe-Censored proposes. The reason is that using the file system is clunkier than a database, you have to come up with file naming conventions to identify each file and associate it to a certain user, and it's going to be awkward if you have to perform searches or filtering on a long list of files.

    If you're familiar with the basics of SQL you should be better off with using a DB storing the XML as text.

    A text field. Simple as that.
    Plain HTTP calls. Again your XML is just text and it can be easily transmitted via HTTP POST calls.

    Good luck
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Clunkier, but if you're putting the XML contents into the database you will then have to parse the XML files to avoid issues like SQL attacks. Someone brand new to databases like the OP I'd just suggest avoiding that altogether for now. YMMV
     
    MrsPiggy likes this.
  5. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    I agree to a point but when you're letting people uploading content to your server, you will need to be familiar with the common vectors of attack and be prepared to block them before they happen, regardless of the medium you're using for storage.
    It's not that the file system is easier to protect from all kinds of misuses (i.e. generating too many files, using illegal characters for file names, generating too big files, etc...)