What's the Command equivalent in Photon ?

Options
I have the following code and i'm looking to rewrite it for Photon. What's the equivalent ?
[Command(channel = (int)QosType.Unreliable)] private void CmdSetInputParameters(float horizontalMovement, float forwardMovement, Quaternion lookRotation) { m_HorizontalMovement = horizontalMovement; m_ForwardMovement = forwardMovement; m_LookRotation = lookRotation; RpcSetInputParameters(horizontalMovement, forwardMovement, lookRotation); } /// <summary> /// Set the input parameters on the client. /// </summary> /// <param name="horizontalMovement">-1 to 1 value specifying the amount of horizontal movement.</param> /// <param name="forwardMovement">-1 to 1 value specifying the amount of forward movement.</param> /// <param name="lookRotation">The direction the character should look or move relative to.</param> [ClientRpc(channel = (int)QosType.Unreliable)] private void RpcSetInputParameters(float horizontalMovement, float forwardMovement, Quaternion lookRotation) { // The parameters would have already been set if a local player. if (isLocalPlayer) { return; } m_HorizontalMovement = horizontalMovement; m_ForwardMovement = forwardMovement; m_LookRotation = lookRotation; }
https://docs.unity3d.com/ScriptReference/Networking.CommandAttribute.html

Comments

  • jeanfabre
    Options
    Hi,

    The Command ( sending from a client to a server) concept in Unet isn't application within Photon, since photon uses RPC both ways, and use a simpler concept of owership for a given networkView.

    In your case, you would directly send the input from the owner to all its instances across the network. You don't need to first send a command to the server that in turns sends an RPC to all instances. You communicate directly, without caring about the server at all.

    for even more power and flexibility, you can use raiseEvent which then allows you to customize your messages, without reyling on the concept of ownership.

    https://doc.photonengine.com/en/pun/current/tutorials/rpcsandraiseevent

    Bye,

    Jean