I’m just learning about Unity Game Services (UGS) so forgive me if I butcher the terminology.
I’m currently developing an asynchronous turn based game. At the moment, I’m using playfab as a baas with azure functions. I’m also using azure webpubsub and websockets for messaging. Lastly, I’m using playfab for the push notifications along with the Unity mobile package.
I’d like to simplify so I’m only using Unity and UGS if possible (i.e. move my azure function code to unity Cloud Code). From what I can tell, UGS has most of what I need but I’d like to clarify a couple of use cases.
The general flow of the app is user authenticates via playfab, gets pubsub connection via playfab api azure function call and connects to pubsub hub. Most calls then go through the pubsub where the ‘backend’ handles them and calls the playfab api if needed. The pubsub is basically acting as a relay server, as currently most of the game logic is on the client (which will change eventually).
Here are the clarifications I need:
Push notifications -
When a player in a multiplayer game makes a move, a message is sent via pub sub to the backend, the backend logs the move, updates the shared data on playfab, and sends a push notification via playfab api to the opponent letting them know a move has been made.
I know you can do push notification campaigns via the Unity Cloud Dashboard, but can I send push notifications for various events via cloud code as described above?
Player messaging -
Currently, players can only message each other if they have an active game and only while in the active game screen. The client sends a message to the backend via pubsub hub, which then sends the message to the opponent if they are in an active game.
I saw there is friend list and friend messaging, which is great, but can I also set up something similar to what I have using only UGS without the need for a multiplay game server or azure pubsub? I.e. Non-friend players can message each other if they are in an active game? I suppose a workaround could be to make the messaging part of the game data?
Lastly, from what I gather, this seems to be the scenario I would setup.
I would move my game logic from azure to Cloud Code (via custom module?). Player data and match data will be saved on Cloud Save.
Player authenticates with UGS via client. Client can then call the various functions in Cloud Code via the UGS api, which can then access data on Cloud Save.
More specifically, player 1 challenges player 2 to an async match via call to Cloud Code which notifies player 2 they have been challenged (in game if active, or via push notification if not).
Player 2 accepts challenge, player 1 receives push notification of acceptance, cloud code logic initializes game data and saves it to cloud save.
Player 1 makes move, which calls cloud code with updated state, cloud logic verifies and saves updated state to cloud save, sends notification and updated game state to player 2.
Also, even though player 1 and player 2 are not friends, they can message each other (via the client in game screen only)
And on and on.
Does this all seem doable with the current state of UGS?
If there are any specific tutorials for these scenarios, the links would be much appreciated.