Search Unity

Third Party Photon RPC animation

Discussion in 'Multiplayer' started by rmele09, May 31, 2015.

  1. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    I am trying to understand the most simple way to send an animation that is playing to clients with photon. I want to use RPC calling. So if I have a function like the one below, which plays a casting animation on a character, how can I send this animation via RPC to everybody in the room?

    Code (CSharp):
    1. IEnumerator RightBlastMix ()                                      
    2. {
    3.     freyaMixRightBlast = false;
    4.     GetComponent<Animation>()["F_RightBlast"].AddMixingTransform(freyaSpine1);
    5.     GetComponent<Animation>().CrossFade("F_RightBlast");
    6.     yield  return new WaitForSeconds (1.0f);
    7.     //yield WaitForSeconds (GetComponent.<Animation>()["F_LeftCast"].length);
    8.     GetComponent<Animation>()["F_RightBlast"].RemoveMixingTransform(freyaSpine1);
    9.     freyaMixRightBlast = true;
    10. }
     
  2. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    171
    Here is how it would work.
    Code (CSharp):
    1. [RPC]
    2. void playNetworkAnim ()
    3.     animation. Play ();
    4.  
    5. void playLocalAnim ()
    6.     animation.Play ();
    7.     photonView.RPC ("playNetworkAnim", PhotonTargets.Others) ;