SendRate









How do I use Send Rate
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonTransformViewPositionControl.cs Copy
132     public Vector3 GetExtrapolatedPositionOffset()
133     {
134         float timePassed = (float)( PhotonNetwork.time - m_LastSerializeTime );
135
136         if( m_Model.ExtrapolateIncludingRoundTripTime == true )
137         {
138             timePassed += (float)PhotonNetwork.GetPing() / 1000f;
139         }
140
141         Vector3 extrapolatePosition = Vector3.zero;
142
143         switch( m_Model.ExtrapolateOption )
144         {
145         case PhotonTransformViewPositionModel.ExtrapolateOptions.SynchronizeValues:
146             Quaternion turnRotation = Quaternion.Euler( 0, m_SynchronizedTurnSpeed * timePassed, 0 );
147             extrapolatePosition = turnRotation * ( m_SynchronizedSpeed * timePassed );
148             break;
149         case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
150             Vector3 moveDirection = ( m_NetworkPosition - GetOldestStoredNetworkPosition() ).normalized;
151
152             extrapolatePosition = moveDirection * m_Model.ExtrapolateSpeed * timePassed;
153             break;
154         case PhotonTransformViewPositionModel.ExtrapolateOptions.EstimateSpeedAndTurn:
155             Vector3 moveDelta = ( m_NetworkPosition - GetOldestStoredNetworkPosition() ) * PhotonNetwork.sendRateOnSerialize;
156             extrapolatePosition = moveDelta * timePassed;
157             break;
158         }
159
160         return extrapolatePosition;
161     }
File name: PhotonHandler.cs Copy
24     public int updateIntervalOnSerialize; // time [ms] between consecutive RunViewUpdate calls (sending syncs, etc)
35     protected void Awake()
36     {
37         if (SP != null && SP != this && SP.gameObject != null)
38         {
39             GameObject.DestroyImmediate(SP.gameObject);
40         }
41
42         SP = this;
43         DontDestroyOnLoad(this.gameObject);
44
45         this.updateInterval = 1000 / PhotonNetwork.sendRate;
46         this.updateIntervalOnSerialize = 1000 / PhotonNetwork.sendRateOnSerialize;
47
48         PhotonHandler.StartFallbackSendAckThread();
49     }
File name: PhotonNetwork.cs Copy
644     {
645         get
646         {
647             return 1000 / sendInterval;
648         }
649
650         set
651         {
652             sendInterval = 1000 / value;
653             if (photonMono != null)
654             {
655                 photonMono.updateInterval = sendInterval;
656             }
657
658             if (value < sendRateOnSerialize)
659             {
660                 // sendRateOnSerialize needs to be <= sendRate
661                 sendRateOnSerialize = value;
662             }
663         }
664     }
File name: PhotonNetwork.cs Copy
674     {
675         get
676         {
677             return 1000 / sendIntervalOnSerialize;
678         }
679
680         set
681         {
682             if (value > sendRate)
683             {
684                 Debug.LogError("Error, can not set the OnSerialize SendRate more often then the overall SendRate");
685                 value = sendRate;
686             }
687
688             sendIntervalOnSerialize = 1000 / value;
689             if (photonMono != null)
690             {
691                 photonMono.updateIntervalOnSerialize = sendIntervalOnSerialize;
692             }
693         }
694     }

SendRate 181 lượt xem

Gõ tìm kiếm nhanh...