Advertisement
dnnkeeper

Untitled

May 24th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. void  OnSerializeNetworkView ( BitStream stream ,   NetworkMessageInfo info  ){
  2.     if (stream.isWriting){
  3.         //МЫ ОТСЫЛАЕМ ДАННЫЕ
  4.        
  5.         Vector3 pos = transform.position;      
  6.         stream.Serialize(ref pos); //"Encode" it, and send it
  7.                
  8.     }else{
  9.         //МЫ ПРИНИМАЕМ ДАННЫЕ
  10.        
  11.         Vector3 posReceive = Vector3.zero;
  12.         stream.Serialize(ref posReceive); //"Decode" it and receive it
  13.        
  14.         //We've just recieved the current servers position of this object in 'posReceive'.
  15.        
  16.         transform.position = posReceive;       
  17.         //To reduce laggy movement a bit you could comment the line above and use position lerping below instead:  
  18.         //transform.position = Vector3.Lerp(transform.position, posReceive, 0.9f); //"lerp" to the posReceive by 90%
  19.        
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement