Search Unity

How to get started

Discussion in 'Multiplayer' started by NeoKuro, Jun 15, 2015.

  1. NeoKuro

    NeoKuro

    Joined:
    Jan 30, 2015
    Posts:
    20
    Hi all,

    I'll cut right to the chase, I'm hoping to create a relatively simple 2D Simulator game. It essentially simulates a world and players login/connect and interact with each other (Trade etc - for those that know of these games, think Europa Universalis IV). Now I'm fairly confident I can create the actual game (Client?). And I've a reasonable/minimal amount of experience in create and managing databases to communicate with a client (Directly, not through a server/multi-user thingy)

    I have a rough idea about how I would go about doing this, I think, correct me if I'm wrong, but I imagined something like having the client hosted on a website (or standalone - not sure what is easier) which connects to a custom server/script/program that is what connects to the Database. This 'middle-man' is what does all the server commands (SQL commands and what not), and returns the result which is what the client accesses. To me it seems relatively simple to do (bit more long winded than just doing directly, but being a new/junior programmer I should probably start considering security issues too)

    So essentially, there are three parts.

    Client/Game that the users use to play the game/interact with the database etc

    Middle-man program/server. Separate program running that handles all SQL Commands.

    Database that stores all the player information (login, stats etc etc)

    I hope I'm correct (at least I understand what to do - which is a start xD) but I don't really know how to go about doing the middle-man/server part. If it was a class within the client, it'd be easy, but kinda defeats the purpose of having a middle-man.

    Anyway, if anyone has any resources, or can help me get started I'd greatly appreciate it, as I've wanted to do something like this for a while, just been discouraged because I realize it is a LOT of effort, and its very daunting lol.
     
  2. Artenio

    Artenio

    Joined:
    Jun 12, 2015
    Posts:
    8
    I'm interessed in something like that, so i #follow this topic :)
     
  3. NeoKuro

    NeoKuro

    Joined:
    Jan 30, 2015
    Posts:
    20
    Ok so I have the basics of it. I have set it up this way;

    1. Server Program/Project - an entire project dedicated to launching and running a server (intended to be a 'dedicated server'). I intend this to be the 'middle man' that connects to and speaks with the Database

    2. Client Program/Project - the game. Completely separate project from the Server program, it connects to the server, and passes in arguments (commands). Be it requesting data, updates, deleting stuff etcetc. But it doesn't link with the database directly (it passes the arguments to the server, and then the server converts the request into an SQL command and returns the result)

    So far, I have the server and client bases setup. The server successfully launches on my local machine (IP 127.0.0.1) on a defined port. And the client successfully connects to it.

    However, beyond that I'm stuck, I have no idea what I'm doing wrong, but to test my theory/get the baseline of what I want to do (pass over commands) I was trying a simple "press button in client, to send a command to the server to print "HELLO WORLD!" on the console when it receives this command". Sadly this is not the case, I have had both of the following happening;

    a. The "[Command] CmdSendCommand() { Debug.log("HELLO"); } " function executes successfully. However does NOT send or execute on the server, it instead simply prints out the string on the client's console, serverside nothing happens - Here my classes inherit Monodevelop

    b. I'm unsure if the function above executes properly, as I get an error in the client console saying something like;
    "Function [Command] CmdSendCommand executed on Server
    ...Debug.logerror(object)" - The difference here is I'm inheriting NetworkBehaviour instead of Monodevelop

    Am I using [Command] (RPC) incorrectly? Is what I'm wanting to do not possible? Any help would be appreciated.
     
  4. Artenio

    Artenio

    Joined:
    Jun 12, 2015
    Posts:
    8
    What do you used to make networking? i want to get at your point so maybe i can help to solve your problem :)