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

Unity and Google App Engine Backend

Discussion in 'Multiplayer' started by Bugfoot, Jan 20, 2011.

  1. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I've got an idea for a kind of multi-player turn-based game I'd like to develop with Unity. I want this game to be playable on the popular platforms: iOS, Android and Desktop (probably WebPlayer, but I could go for standalone too). It's going to require persistent storage of user progress (such as level and xp) and a way to notify each player of the other player's move. Think asynchronous chess game, where each player can perform one move per turn.

    My initial thought was to develop my game backend as for Google App Engine (GAE). The clients would periodically poll the backend via HTTP request to retrieve the latest game state. The main reason I'm going for GAE is scalability and ease of development. I don't want to have to worry about hosting and scalability issues down the line.

    Now I'm already running in a few road-bumps when it comes to interfacing my backend with Unity. For my game, I must be able to uniquely identify users as I will be storing persistent data for each of them. This means I need a user management system with account login and session. GAE natively supports Google's Account service, which takes care of most of that stuff for you. However, the catch is that it doesn't have an API method for programmatically signing in a user with a username password, nor create a new account. Instead, you have to forward the user to Google's account sign-up URL. And this requires a web browser. I would like to be able to do this from within my game. The other alternative is to write my own user authentication system, but I'm really not excited about the idea.

    So has anyone tried to do something similar for their game, and found a good workaround/solution to this problem? Do you have another tech suggestion to implement my server backend, given my constraints (Unity client + crossplatform + HTTP only)?

    Thanks in advance!
     
  2. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Quick update: I came across the Tipfy framework (python) for Google App engine. It has support for custom user auth and session, and it works pretty well so far.

    I can now login with a username password from my unity client. I've had to bend some corners with Unity's built-in http request class (WWW) in order to retrieve the auth session cookie and submit it as part of the HTTP header in subsequent requests to my backend but it works :) I'm also using POST method only as it seems to be the only way to provide custom headers with Unity's current implementation of the WWW class. I would like to be able to do that with GET method as well.
     
  3. hperantunes

    hperantunes

    Joined:
    Mar 27, 2011
    Posts:
    1
    I'm also looking at GAE for the backend engine. Nice to know that authentication with Tipfy worked for you.

    Any further progress?
     
  4. jpa

    jpa

    Joined:
    Nov 11, 2010
    Posts:
    3
    I am also playing around with GAE with unity. Have you looked into the Channel API? It's actually built for mplayer game type concepts

    http://code.google.com/appengine/docs/python/channel/overview.html

    It lets you rebroadcast updates to all listeners on a channel without polling. I wouldn't use it for any low latency stuff like player movement, but it could work for a lot of stuff.

    I got the tic-tac-toe running in my sandbox, been playing around with it. I haven't hooked it up to Unity client yet (Im new to Unity)

    Also, check out XMPP for chat
    http://code.google.com/appengine/docs/python/xmpp/overview.html

    Here is a xmpp client for mono, but I havent tried using it in Unity yet.
    http://www.ag-software.de/agsxmpp-sdk/
     
  5. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    [edit] This is not longer available on Asset Store but I did include the sources in a post lower down in this thread.

    If anyone is looking for this kind of Google App Engine (GAE) support you could have a look at the package I released. It is based on the tech behind my new game, Battlemass (a turn-based multiplayer strategy game)

     
    Last edited: Sep 18, 2014
  6. Almog

    Almog

    Joined:
    Nov 20, 2011
    Posts:
    22
    There is also Scoreoid it's an easier solution need to develop your own it does user saves and log-in - http://www.scoreoid.net/

    Scoreoid, developed by game developers for game developers, is a non-restrictive, reliable and easy to use gaming platform designed to handle but not limited to scoring, leaderboards and game management, including advanced functions such as platform content awareness, for multi-platform games.

    Scoroid’s goal is to make games better by handling advanced features, shortening game development time and costs, and freeing up developer time to focus on their games.
     
  7. infamouspip

    infamouspip

    Joined:
    Oct 3, 2012
    Posts:
    2
    Hi. Thanks for starting this thread (I realise it was a while ago), since I'm thinking along very similar lines for my game, and it's really useful to see how other people have solved the same sort of problems.

    Tipfy looks awesome, which is annoying since I have to use the Java side of GAE (I've got shared code between the backend and Unity, and Java is the only common language). Does anybody know of a Java equivalent to Tipfy?

    In any case, my first thought is that if GAE natively supports Google Accounts, then sure our Unity projects could just have the player enter their username and password, forward it to the backend, which would handle the sign-in grammatically (as opposed to forwarding to the login page). I can't see precisely how to do that last bit though. Do you think it's possible?
     
  8. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Wow, Scoreoid actually looks pretty nifty. Nice to see that there are Unity examples provided :)
     
  9. akkiDev

    akkiDev

    Joined:
    Aug 7, 2013
    Posts:
    70
  10. SleepingZebra

    SleepingZebra

    Joined:
    Apr 20, 2014
    Posts:
    1
    I bumped into this page when looking for Google Cloud Backend starter kit. Surprised that there is no client or plugin or endpoint for Unity yet.

    Although there are other cloud services (I used Parse which is horribly slow in UK and EU), I am keen to use Google Cloud because of their massive data centres.

    Any help from Unity community would be greatly appreciated to all Unity game developers out there.
     
  11. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Just in case someone views this thread and is looking for something to get started with. I've attached a solution I developed back in 2011. It is old and will probably throw some errors against the latest Unity and Google App Engine but might be helpful in getting started.
     

    Attached Files:

    Kabeza and jprocha101 like this.
  12. Kabeza

    Kabeza

    Joined:
    Aug 31, 2015
    Posts:
    4
    thanks!