Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Temporarily Disable Photon View Sync

$
0
0
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!

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>