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.

Server side with PHP and Webservices

Discussion in 'Multiplayer' started by tomcat, Mar 30, 2009.

  1. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Hi,

    I like to create my serverside code with PHP and user web services to talk to it. Knowing very little about the way Unity does its client server operation, is this a practical thing to do?

    tomcat
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Yupp practical and pretty simple :)

    The WWW and WWWForm classes are best friends of you in this case.
     
  3. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Great. Just had a look at the runtime classes and I think I get it. Can see a perl example but not a php one.

    1) Have you seen any php server side example, so I can figure out what to do at that end?

    2) BTW, does it mean that I can do my own server and not using the unity's client/server model?

    tomcat
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    1) do not fully understand, sorry. On PHP its $_POST["your variable name"] and whatever you send to the page and back

    2) No, WWW / WWWForm is HTTP communication
    For realtime games you either have to use unitys networking or integrate a 3rd party solution or work with .NET Sockets
     
  5. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Ok, so for low bandwidth and casual communication WWW is good, but if I have many users (I am going to have about 100), I have to use unity's networking which is raknet.

    Do I have to pay to use raknet? or is there a free version?

    tomcat
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No not exactly.
    The WWW is only usable for web communication or very low frequency turn based games handled by a CGI / PHP end (basically a Unity version of a browser game)

    Anything thats more realtime requires unity networking or a 3rd party networking.

    The networking integrated into the unity clients can be used for free.
     
  7. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Ok, so I can create a game supporting about 100 users (running unity clients) which can talk to a single server running on a remote site. This wouldn't cost me anything.

    If I want to support more users, then I have to use something else like raknet which would then cost me. Is this right?

    tomcat
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Yes and no
    There is no Unity Server
    Only the client which you would use as server if you want to run something like a dedicated server.
    That would be free yes.

    But you can not run that on a remote website. You need to have a (virtual) dedicated Windows / OSX Server
    You can not run realtime game servers on webhosts

    (already browser game type server loads are commonly not allowed on webhosts)
     
  9. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Yes, I see. I got to get a co-located server where I can run my own server software or host it at home.

    I guess I have to run it on a webplayer and develop my own server using WWW to exchange data between client and the server.

    I guess there is no chance of creating a simple world shared between clients as the comms overhead makes it slow to update the world!!

    tomcat