The Prophet The Prophet - 2 months ago 16
C# Question

How to synchronize sprite changes (SpriteRenderer) in Photon Unity?

So, when I press space, my players sprite changes to another sprite. How can I make it so that others see this? I have tried dragging the SpriteRenderer component to Photon View observable list, but nothing.

Answer

Use the PhotonTargets.AllBuffered parameter in the RPC call as this will send the RPC to everyone else and executes it immediately on this client. Used Photon once and not a pro. Don't know much has changed since then but this will likely solve your problem.

void Start()
{
    if (photonView.isMine)
    {
        photonView.RPC("changeSprite", PhotonTargets.AllBuffered, null);
    }
}

[RPC]
void changeSprite()
{
    //Out Change Sprite code here
}