Синтаксис:
Используется csharp
void Update () {
if (photonView.isMine) {
// Do nothing -- the character motor/input/etc... is moving us
}else {
transform.position = Vector3.Lerp (transform.position, realPosition, CharLerping);
transform.rotation = Quaternion.Lerp (transform.rotation, realRotation, CharLerping);
}
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if (stream.isWriting) {
// This is OUR player. We need to send our actual position to the network.
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);\
}else {
// This is someone else's player. We need to receive their position (as of a few
// millisecond ago, and update our version of that player.
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
if(gotFirstUpdate == false) {
transform.position = realPosition;
transform.rotation = realRotation;
gotFirstUpdate = true;
}
}
}