Photon Unity NetWorking的一些注意事项


转载自官网技术文章

在PUN中設定封包的傳送信賴度

在PUN中,可透過PhotonView元件中的Observe option變更設定。

在Observe option中
・Unreliable: 將不確認封包是否有被送達,僅專注於發送訊息。
・Unreliable On Change:性質上與Unreliable相同,且僅在有變更時發送訊息。
・Reliable Delta Compressed:會自動針對顧客最後收到的數據與目前狀態的數據進行比較,如果數據沒有任何變動,就不會發送數據。反之則會發送數據。

如果只有使用RPC的話,建議可將Observe Option設定為Off,使物件從被觀察物件中除名,如此將能讓收發訊息的量再更輕減。

 

關於PUN的PhotonView收發訊息相關規格

  1. 關於PhotonView訊息數量的計算方法
    在PhotonView中,會彙整所有腳本,並視為訊息數量進行計算。雖然訊息數量一般都很小,但若訊息量愈來愈大時,有可能會發生碎片化的情形。
  2. 關於 Reliable Delta CompressedUnreliable On Change
    數值未變動或OnPhotonSerializeView以NULL傳回時,將不會傳送訊息。接收端的OnPhotonSerializeView也不會被叫出。

關於Master client應用程式休眠時的對應

當Master client的應用程式進入休眠時,為使同一房間內的玩家可以正常操作遊戲,並且自由參加或離開房間,Photon Unity Networking(PUN) v1.62新增了PhotonNetwork.BackgroundTimeout的功能。

Unity叫出OnApplicationPause時,可以設定要在幾秒內、進行關閉與否。

此一功能在預設中的設定雖然是關閉的,但您可用此種方式連接長期處於背景中的玩家。

PhotonAnimatorView的animator参数同步模式

Discrete synchronization means that a value gets sent 10 times a second (in OnPhotonSerializeView). The receiving clients pass the value on to their local Animator.

Continuous synchronization means that the PhotonAnimatorView runs every frames. When OnPhotonSerializeView is called (10 times per second), the values recorded since the last call are sent together. The receiving client then applies the values in sequence to retain smooth transitions. While this mode is smoother, it also sends more data to achieve this effect.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM