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

can Firebase be used to backend Unity MMOs?

Discussion in 'Multiplayer' started by ChipN, Mar 12, 2013.

  1. ChipN

    ChipN

    Joined:
    Mar 12, 2013
    Posts:
    2
    The Firebase real-time replicating database system seems to offer the potential of running a server-less MMO. Has anyone tried? Do MMOs typically need server-side logic or can client-side access to real-time data provide the necessary facility? Do things need to be faster than millisecond-range response times?
     
    Last edited: Mar 12, 2013
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    I doubt this will work fast enough, from what I can see they use http which isn't fast enough.
     
  3. JamesPro

    JamesPro

    Joined:
    Mar 5, 2012
    Posts:
    509
    lol You would NEVER want to give the Client access to the Database. There would HAVE to be Server Side Logic for anything that could give the player a unfair advantage should they hack their client. If you don't you would be dealing with a HUGE amount of hacking and people wouldn't want to play the game...
     
  4. ChipN

    ChipN

    Joined:
    Mar 12, 2013
    Posts:
    2
    Thank you.
     
  5. GregFirebase

    GregFirebase

    Joined:
    Mar 12, 2013
    Posts:
    2
    Hi, Firebase dev here. I'd like to address some of the issues that were brought up above.

    1. Firebase runs over websockets in all browsers that support them. The performance characteristics will be about what you'd get with a plain tcp connection.

    2. While Firebase is a database accessible via the client, it also provides a robust and granular security model to help devs secure their app and prevent cheating in their games. Firebase supports some basic authentication options (email/password, facebook, twitter, others...), plus supports you doing authentication on your own server via a JSON Web Token, an open standard. You can even use a third-party authentication service, like Singly.com, which connects you to dozens of other auth providers.

    Once you have a user in your system, you can use Firebase's Security Rules to secure what they can read and write. If you're curious, I advise you to check out the screencast here: https://www.firebase.com/docs/security-quickstart.html. It goes over how you can secure a client-side app with Firebase.

    I hope that addresses the concerns that have been brought up. Please don't hesitate to ask any more questions you might have.

    Edit: as an example of a multiplayer, in-browser game powered by Firebase, check out roll20.net, a virtual table-top gaming site.
     
    Last edited: Mar 12, 2013
    xAdamQ and TheGering like this.
  6. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Welcome to Unity, Greg!

    Although I'm working on a single player game, I like to stay abreast of multiplayer / MMO development. I visited your website, worked through your very intuitive tutorial and played around with some of the examples. The speed of the connection seems fine. Perhaps not for realtime FPS, but certainly for traditional MMO needs.

    Sounds like security is handled. I'll take your word for it for the timebeing.

    What about rooms? Your How It Works page says "Whenever your data changes, all clients are immediately notified within milliseconds." For most MMOs, updates should only be sent to users that are in the immediate vicinity of each other. Outdoor Unity scenes would need to be subdivided into rooms otherwise there is too much data being sent. How would you handle that with Firebase?

    Any plans to develop a Unity Firebase Integration? Perhaps Photon users should be looking at Firebase as a persistence solution since Photon doesn't handle that.

    Interesting stuff.
     
    Last edited: Mar 19, 2013
  7. GregFirebase

    GregFirebase

    Joined:
    Mar 12, 2013
    Posts:
    2
    Hi Nixter,

    When the docs say "all clients are immediately notified within milliseconds", it really means, all clients who are currently registered to watch the data at that location. The API lets you control what data each client is watching.

    So, you might have a data layout like this:
    root
    |
    +-- rooms
    |
    +-- room1
    |
    +-- room2

    Clients in room1 would be watching /rooms/room1, and clients in room2 would be watching /rooms/room2.

    When a user moves from room1 to room2, you can update the locations that the client is watching.

    I encourage you to check out the tutorial on our website, which walks you through creating a chatroom. The same principle should be applicable to a multiplayer game with rooms.

    As for an official integration, we may do one at some point. In the meantime, I wrote some notes about what an integration might look like as an answer to this question on stackoverflow: http://stackoverflow.com/questions/15352252/using-firebase-to-backend-unity3d-for-the-creation-of-mmos/15353456?noredirect=1#comment21700978_15353456.

    For questions regarding Firebase, the best place to go is our google group: https://groups.google.com/forum/?fromgroups#!forum/firebase-talk
     
  8. squidbot

    squidbot

    Joined:
    Jan 4, 2011
    Posts:
    128
    I've been using Firebase since beta, and it's actually a great tool for use as a game backend, and I think it could support a traditional mmo fairly well. Because you can select which clients listen to what messages, you could can set up a "client" which is actually a game rules server that checks listens to messages that need to be authenticated (combat results, inventory, etc.) and then have it "repeat" those messages to the customer clients. Other messages like position updates might go straight to other customer clients for responsiveness, as well as be checked by the game rules client for accuracy.

    The "hard part" would be putting the first "M" in MMO, which would be appropriate scaling for your game rules client, but for prototyping at least, Firebase would be a great option.
     
  9. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I would like to see an example integration as I'm considering it for an upcoming project.
     
  10. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Wow this is quite interesting.
     
  11. Ohmnastrum

    Ohmnastrum

    Joined:
    Mar 4, 2013
    Posts:
    1
    Using the security api would it be possible to perform input validation? things like a user has hacked their client to deal more damage than allowed, or step further than usual? Would it result in completely dropping the transmission or could it be automatically scaled back to fit expected parameters?
     
  12. wolfgangmeyers

    wolfgangmeyers

    Joined:
    Mar 30, 2012
    Posts:
    2
    Ohmnastrum the security api doesn't deal with this because it would be specific to the rules of your game, but an example that I saw that would address this involved hooking up a backend server to watch and validate changes to the data.
     
  13. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Hi @GregFirebase if you're still there.

    I love Firebase but I've always found it strange/bizarre you didn't go hell for leather for Unity.

    iOS and Android - who cares? the games market is where it's at and Unity is the games market.

    Say Firebase was a film company. And say you were really into making "foreign films" or maybe "Woody Allen films". That's what Firebase seems to be doing at the moment ... iOS and Android? what's the goal, like the important accounting app market? :) In the film company analogy, Firebase should be going for the main market, ie, sci-fi films and family CG films, just like any major studio.

    So, I urge you to forget about this bizarre native iOs/Android crap and concentrate on the (by far) world's main market, games.

    Now what i wanted to ask, if you're still on this list.......

    https://www.firebase.com/blog/2015-12-18-firebase-unity.html the beta was released some four months ago now. That is like 10 years in dog or software years you know?

    Is it time that Firebase should tell us "well we've given up and won't be doing Unity" ... ? Or is the first release right around the corner?

    what's the deal, Firebase? Please let us know!
     
  14. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    New Firebase looks good...

    https://scotch.io/bar-talk/a-look-at-the-new-firebase-a-powerful-google-platform

    http://techcrunch.com/2016/05/18/go...o-its-unified-platform-for-mobile-developers/

    Update on Unity here:
    https://groups.google.com/forum/?fr.../unity/firebase-talk/h_8Kt8KYDv8/WaTpSTMxCAAJ

    "Correct. There seems to be good interest in Unity now, so I'd expect this to get discussed/addressed in the near future."

    I bet over 80% of games on the Play store use Unity, so hopefully they will put some time into this.

    Someone else make a plugin for sale on the asset store?
     
  15. takealuke

    takealuke

    Joined:
    Feb 19, 2016
    Posts:
    6
    My main question for anybody using Firebase: what are the best practices for write frequency? Say I'm building a driving sim, and I want to track current speed -- and have that show up in the DB in real time. Should I write to firebase on every frame? FixedUpdate? Or should I be gentle and write every 60/100/200 frames?
     
  16. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Hi Luke, you certainly would not write "continuously". Absolutely no need for that, and it wouldn't work.

    I'd say write every "5 seconds", perhaps.

    In many cases, simply write at the end of the race.

    Don't forget: recording ghost racing is tricky. You have to record the real actual time (on input) ........ and interpolate that when you come back the other way. The frames won't be "in the same place"!

    It's only a few lines of code, but you have to get it right. It's one of those issues where the general idea is simple, but the actual engineering is tough.
     
    Last edited: Aug 15, 2016
  17. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    156
    So is there any one using FireBase for Unity game backend?
     
  18. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    I wish there was a decent Firebase plugin for unity

     
    zyzyx likes this.
  19. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    I wish too :(
    Dang
     
  20. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Yes, it's total madness that google have not covered Unity, with Firebase. However, they screwed up - Unity's own DATA service is coming soon.
     
  21. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
  22. RafaelAlcantara

    RafaelAlcantara

    Joined:
    Mar 30, 2016
    Posts:
    11
    Unity's own data service? I'd like to know more about it...
     
  23. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    https://data.cloud.unity3d.com/#/landing

    "Unity Cloud Data – Ever needed to change a variable in your game, but don’t want to make a new build? Are players telling you the game is too easy or hard? Cloud Data lets you store variables and values of your game in Unity Cloud, minimizing development time for quick changes. In the demo, the team tweaked gravity values, spawn rate and fire rate in a game, which automatically updated the variables on launch."

    https://blogs.unity3d.com/2015/01/12/celebrating-our-first-cloud-hack-week/

    However I emailed them in 2015 and didn't hear back, so not sure how this service is progressing.
     
  24. mofirouz

    mofirouz

    Joined:
    Jul 14, 2015
    Posts:
    27
    I'm a little late to the party but for whoever ends up reading this. I've been working on an alternative to both Firebase and any realtime multiplayer system (likes of Photon). I've made it entirely open source and you can find it here.

    It allows for data storage per person and has a data permissioning system similar to Firebase in that you can allow other player to read your data, this can lead to interesting results like user generated contents or maps etc. On the otherside, the multiplayer is realtime (and uses Websockets and protocol buffers for small, fast payloads) and session and player presence notifications is handled on the server completely transparently. We use this to power realtime chat as well.

    You can find the unity package here.

    Would love some thoughts on the full features list.
     
    recon0303 likes this.
  25. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    Sadly it looks like Unity Cloud DB is dead:

    https://forum.unity3d.com/threads/unity-cloud-db.464696/#post-3021715