Question by
RainKiller27 · Jan 25, 2016 at 11:18 AM ·
networkingplayerphoton
Can't see other players on the server
Hello I have followed the Photon tutorial to get the network working, it worked on my other project but every time I try to smooth the network movement out I can't see the other player could anyone tell me why this is happening?
using UnityEngine;
using Photon;
public class NetworkPlayer : Photon.MonoBehaviour
{
private Vector3 correctPlayerPos;
private Quaternion correctPlayerRot;
// Update is called once per frame
void Update()
{
if (!photonView.isMine)
{
transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp(transform.rotation, this.correctPlayerRot, Time.deltaTime * 5);
}
}
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
// Network player, receive data
this.correctPlayerPos = (Vector3)stream.ReceiveNext();
this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
}
}
}
Comment
Best Answer
Answer by RainKiller27 · Jan 25, 2016 at 11:45 AM
Fixed it myself added a photon view to the scene which fixed the problem!