Synchronisation Annimation via RPC call

Options
Hello,

I'm looking since 1 week a way to synchornise my annimation via a RPC call.

I have my two player connect in my game.
One of them is punching , so he is playing the annimation "Punch".
I would like the other player to see him punching but without having to put code in the "OnPhotonSerializeView()" function because this action doesn't have to be synchronise every frame but only when the player is pressing a key.

For the moment i have this code .

I read the input and play the annimation and start a coroutine to say when the punch is finish ( at the end of the annimation):
                if (InputManager.Instance.IsPassing && !hasBall && view.isMine)
                {
                    pc.SetParameterBool("Kick", true);
                    Invoke("AttaqueFinish", pc.GetTimeCurrentAnAnim(1));
                }
the function SetParameterBool() :
    public void SetParameterBool(string parameter,bool value)
    {
        view.RPC("AnimBool", PhotonTargets.AllBuffered, parameter, value);
    }
the function RPC :smile:

    [PunRPC]
    private void AnimBool(string nameAnim,bool value)
    {
        Debug.LogError("Anim = "+nameAnim+" / value = "+value);
        anim.SetBool(nameAnim, value);
    }
with the debug log i have a value = true for one character and the other one get the value = 0
false.

I tried to put set the value to true everywhere : "view.RPC("AnimBool", PhotonTargets.AllBuffered, parameter, true);" but same like this when all character see the value to true, only the local player see is one punch annimation

So i would like to know if there is any solutions to share this kind of thing via RPC call . Or i have anyway to pass through the function OnPhotonSerializeView() to share all the time the value of my bool punch ?

Regards.

Thibault Coutaz

Comments

  • jeanfabre
    Options
    Hi,

    is there any reason you don't want to use PhotonAnimatorView? Have you tried it?

    -- you should not buffer rpc calls in this case, you don't want new players joining the room to get these rpc, they only are meant to be used when received.

    -- passing through OnPhotonSerializeView() is likely a better option, however the way many developers and artists work now with the Animator make automatic synching tricky because they are transitionless and all transition are fired programmatically, so if you are in a case of an animator with only states and no transitions, you'll have work out a way to do that on both side, which likely means a higher level of data sharing then simply animator property values.

    Bye,

    Jean
  • Hi ,

    Thanks for your rely,

    I completly forgot about it and so now i resolve my problem.
    But is it better to share my bool ( because I'm managing my punch animation with a bool and not a trigger ) from this component or with OnPhotonSerializeView().
    I'm just afraid that in a function OnPhotonSerializeView() it will, with all the annimation, share too much datas and maybe cause latence.

    With this component normally i dont have anymore to share anything from the animator in my function OnPhotonSerializeView() is that ?
    This component can handle him self the movement of my player or it's still better to share the movement data in my OnPhotonSerializeView() function because it's some datas that are constantly share ?

    regards

    Thibault Coutaz