Simple Cloud server client test throws errors
Options
Just started using Photon in Unity. I created a simple test almost exactly the same as the DemoWorker one from the Asset Store. After connecting, I join/create a room which spawns a photon view ball the player can move. I open two clients, one running in Unity Editor, one in a browser and this error starts spamming once the browser client joins the room:
My server settings:
PhotonCloud
app.exitgamescloud.com:5055
I spawn the balls with PhotonNetwork.Instantiate once a player has joined the room.
Here is the ball script, just sending position:
This seems simple, what am I doing wrong? Any help?
NullReferenceException: Object reference not set to an instance of an object NetworkingPeer.ObjectIsSameWithInprecision (System.Object one, System.Object two) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2438) NetworkingPeer.DeltaCompressionWrite (.PhotonView view, System.Collections.Hashtable data) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2415) NetworkingPeer.WriteSerializeData (.PhotonView view) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2389) NetworkingPeer.RunViewUpdate () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2279) PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:90)
My server settings:
PhotonCloud
app.exitgamescloud.com:5055
I spawn the balls with PhotonNetwork.Instantiate once a player has joined the room.
Here is the ball script, just sending position:
using UnityEngine; using System.Collections; [RequireComponent(typeof(Rigidbody))] public class Ball : Photon.MonoBehaviour { public float speed = 5; private Vector3 _correctPos = Vector3.zero; private void Awake() { gameObject.name = gameObject.name + photonView.viewID.ID; TextMesh playerName = GetComponentInChildren<TextMesh>(); if (photonView.isMine) { // local player playerName.text = PhotonNetwork.playerName; renderer.material.color = Color.red; } else { // network player playerName.text = PhotonNetwork.otherPlayers[0].name; renderer.material.color = Color.blue; } _correctPos = transform.position; } private void Update() { if (photonView.isMine) { // local player float x = Input.GetAxis("Horizontal") * Time.deltaTime * speed; float y = Input.GetAxis("Vertical") * Time.deltaTime * speed; transform.Translate(x, 0, y); Camera.mainCamera.transform.LookAt(transform); } else { // network player // smooth this, this looks good, at the cost of some accuracy transform.position = Vector3.Lerp(transform.position, _correctPos, Time.deltaTime * 5); } } private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { // local player stream.SendNext(transform.position); } else { // network player _correctPos = (Vector3)stream.ReceiveNext(); } } }
This seems simple, what am I doing wrong? Any help?
0