So I am creating a 1vs1 multiplayer game where the players have to send 3 values to the Cloud script. In the cloud script, the values will be processed then it will return a result to both players. I want to create C# cloud script using azure-functions. The environment is set in vscode. I can create azure function and add this function to PlayFab => Automation => Cloud Script => Functions but unfortunately i can't send or receive value from 1 player to another. I am using this piece of code from the documentation in unity. How can I send, process, and receive value from the Cloud Script using C# azure-function? Thanks in advance!
using System.Collections; using System.Collections.Generic; using UnityEngine; using PlayFab; using PlayFab.ClientModels; using PlayFab.PfEditor.Json; public class NetworkManager : MonoBehaviour { private string playerName = "TestName"; private int playerIndex = 1; private bool isSelected; // Build the request object and access the API public void CloudSendPlayerValues() { PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "helloWorld", // Arbitrary function name (must exist in your uploaded cloud.js file) FunctionParameter = new { name = playerName, playerIndex = playerIndex, isSelected = isSelected }, // The parameter provided to your function GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream }, OnCloudSendPlayerValues, OnErrorShared) ; } private void OnCloudSendPlayerValues(ExecuteCloudScriptResult result) { // CloudScript (Legacy) returns arbitrary results, so you have to evaluate them one step and one parameter at a time Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult)); JsonObject jsonResult = (JsonObject)result.FunctionResult; object messageValue; jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript (Legacy) Debug.Log((string)messageValue); } private void OnErrorShared(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); } }