Temporarily Disable Photon View Sync

Hi all,

I've got a small problem I'm hoping someone can help me with. I'm making a very simple multiplayer shooter to wrap my head around PUN concepts. I have a player object that has a PhotonView Component and an observed PhotonTransformViewClassic, everything has being going great until today when I decided to implement a new projectile that has a knockback effect.

When a projectile collides with a player it calls an RPC function that applies a knockback effect to the player (moves the player back 5 units). Originally I had it so that this function would only be ran if 'photonView.isMine is true', however this meant there would be a slight delay before the knockback took place on the shooters screen (due to latency). I then tried removing the 'if photonView.isMine is true' requirement so that the function would run on all clients. This resulted in the player being knocked back, then warping to its starting position (because photonView was synced and the remote player had not yet initiated its knockback function), and then finally warping back to its knocked back position (the remote player finished it's knockback function and then synced its photonView).

So I had an idea: I would run it on all clients and temporarily disable the TransformViewClassic syncing, and then re-enable it after the knockback function had run on all clients. However, I have no clue how to do this! I tried doing photonView.Synchronization = ViewSynchronization.Off as part of the RPC call, but this resulted in the knockback working as intended, but then the player warping back to it's starting position afterwards.

I'm starting to think that the only way to accomplish this would be to ditch using TransformViewClassic and just write my own synchronization code with a custom IPunObservable implementation.
Does anyone have any ideas? Thanks!


  • Okay, I think I'm on the right track. In the knockback function I first disable synchronization of the TransformViewClassic Position (gameObject.GetComponent<PhotonTransformViewClassic>().m_PositionModel.SynchronizeEnabled = false;) then after the knockback is performed I have another RPC call that re-enables the TransformViewClassic synchronization (only the player who was hit calls this, so we know that player is done moving).

    However I'm still getting some weird behaviour where the player character will warp back and forth a bit on the screen of the player who hit them. Here is the relevant code:

    Knockback coroutine that gets called via an RPC call:
            public IEnumerator CoPlayerKnockback(float duration, float speed, Vector3 direction){
                Debug.Log("Performing Knockback. Duration: " + duration + " Speed: " + speed + " Direction: " + direction);
                lockMovement = true;
                gameObject.GetComponent<PhotonTransformViewClassic>().m_PositionModel.SynchronizeEnabled = false;
                for (float time = duration; time >= 0; time -= Time.fixedDeltaTime){
                    cController.SimpleMove(direction * speed);
                    yield return new WaitForFixedUpdate();
                if (photonView.IsMine) photonView.RPC("RPCEnablePhotonTransformView", RpcTarget.All);
                lockMovement = false;        

            public void RPCEnablePhotonTransformView(){
                gameObject.GetComponent<PhotonTransformViewClassic>().m_PositionModel.SynchronizeEnabled = true;
  • Alright, I've dug through the code on TransformViewClassic and determined why this doesn't work, I've also determined that I'm going to have to roll my own transform synchronization code, or just accept the fact that there will be a slight delay after hitting a target before the knockback is applied (we'll see if this game gets past the prototype stage :D)

    For anyone else that randomly comes across this post and is looking for a solution to this problem, here is why you cannot temporarily disable synchronization for TransformViewClassic:

    For any synchronization after the first one TransformViewClassic updates the position of the gameobject BEFORE it grabs new data from the photonview owner. What this meant for me is that I disable position synchronization, perform my knockback, and then when I re-enable the position synchronization the object is synchronized to it's last known position (the last position the TransformViewClassic had before I disabled it). So the object warps back to its initial position and then when it receives a new position from the owner it then warps to that position.

    I hope this helps any internet strangers!
  • Hey nebiont,
    Thanks for the post!
    Just faced the same issue, have you found the solution with knockback sync without delays?
  • this is great. I am looking for the exact solution. thank you