In a unity MOBILE game where a player needs to see all online other players added by each other. and once one gets offline, or their scores changed, their status gets updated, do I need a real time database? Can this be done with php & Api ?? How to check if there is any update in any player's status?? Thanks


Can this be done with php? Yes, it certainly can. You can perform arbitrary web requests from a Unity game with the class UnityWebRequest.

Will it fulfill your requirements? Maybe, maybe not. We don't know your requirements, so we can only guess.

In general, the communication model of a webservice is pull-only. The client (in your case the Unity game) makes a request, and the server answers. The server can not do push notificaitions. If the server wants to tell the client(s) something it wasn't asked for, like the fact that a new client connected, then there are two workarounds:

  • Long-Polling: Have the client create a request and delay the answer until there is something to report.
  • Hammering: Have the client request status updates from the server at regular intervals.

Neither option is ideal, because they take up considerable resources on the server. So if you want to support a large number of users on a small server and give them near-realtime updates, then you might want to implement your own network protocol using the transport layer API.

Do you need a "realtime database"? If you want to have highscores and user accounts, then using some kind of database is certainly a good idea. But "realtime" is a meaningless marketing buzzword when it comes to databases, which translates to "fast at certain kinds of queries". Again, we don't know your requirements. So we don't know if you need some obscure special product here or if a run-off-the-mill SQL database like mySQL or PostgreSQL will do. But my educated guess is that you will be fine with a regular database.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.