Two Newbie questions

Options
I asked in Unity forums but no one seems to be answering. I want to ask 2 questions related to PUN:

1) Hello, new to Networking, my first multiplayer game, a top-down 2D shmup arena.
I used PUN and everything runned smoothly eventually in my first attemps and tests except a thing. The shmup ships move around and one sees another move smoothly. But a small, a bit lag seems to be created as the game runs and gets bigger and bigger over time. This leads to jumps in the "other" ships' movement about at the 5 minute mark.
I live in Greece and set up the preferences to EU Photon Server. I also tested this to different connections, so I don't think it is a "my" connection problem.
The player observes only one script nested to the "other" ships gameobjects which is the following:
using UnityEngine;
using System.Collections;

public class NetworkCharacter : Photon.MonoBehaviour {

Vector3 realPosition = Vector3.zero;
Quaternion realRotation = Quaternion.identity;


void Start () {

}


void Update () {
if( photonView.isMine ) {

}
else {
transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f);
}
}

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {


stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else {


realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
}

}
}

There are of course 2 other scripts in the ship, one for movement and rotation, and one for camera, but those are not observed.
Anybody has an idea?



2) Furthermore, are there series of up to date video tutorials that explain all the features of PUN? There are some in in Photon website as links, but they are from like 2014. Should I trust them?

Answers

  • i think is probably just you need Time.deltaTime instead of 0.1f

    transform.position = Vector3.Lerp(transform.position, realPosition, Time.deltaTime * movespeed);
    transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, Time.deltaTime * rotationspeed);

    second Q
    the best way to learn is just use the demos that come with pun in unity

    hope this helps