question

sezeraktemur avatar image
sezeraktemur asked

How to call unity code from client to Dedicated Server Unity?

I seperated codes in my Unity Project as 'ServerScripts' and 'ClientScripts'.

ServerScripts will be deploy on Dedicated server and ClientScripts will stay in local so client can't access the ServerScripts.

I wonder that how can i communicate each other? How can i call serverscripts from clients.

SetUserData.cs in a ServerScript folder. So it will not be visible to clients. How clients will call it?

    void SetUserData()
    {
        PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest()
        {
            Data = new Dictionary<string, string>() {
            {"level", "1"},
            {"experience", "0"}
        }
        },
        result => Debug.Log("Successfully updated user data"),
        error => {
            Debug.Log(error.GenerateErrorReport());
        });
    }
unity3dphoton
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

Since calling a server method from a client requires data communication between the client and the server, you need to do some necessary work like defining a data model that contains the information exchanged between the server and the client and implementing the exchange data and parse data function. So, to simplify your networking development process, you can use Network library like Mirror Networking library, which has implemented the data communication between client and server. You can also refer to our MpsSamples/UnityMirror at main PlayFab/MpsSamples GitHub. In addition, Client API can only be used on client-side, so, on server-side, you should call Server API.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sezeraktemur avatar image sezeraktemur commented ·

Since I am going to use Photon, Basically I will call RPC function to call server side function. However, there is no document about 'How to call RPC function on Dedicated Playfab MPS?'

1 Like 1 ·
Xiao Zha avatar image Xiao Zha sezeraktemur commented ·

Since the question is Photon related, please contact Photon Support for assistance.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]