Problems with OnPhotonSerializeView
Options
Hey!
Im trying to implement a flashlight for players in a topdown game and having problems to sync the light. I am pretty new to Photon and coding in general, but after searching for hours i dont know how to slove this.
I put an IPunObservable on it and placed it corretly in the photonview.
My Code:
Im trying to implement a flashlight for players in a topdown game and having problems to sync the light. I am pretty new to Photon and coding in general, but after searching for hours i dont know how to slove this.
I put an IPunObservable on it and placed it corretly in the photonview.
My Code:
void Update() { if (Input.GetKeyDown(KeyCode.F)) { Flash(); } } void Flash() { if (localPlayer == true) { if (flashLightSwitch == 0) { flashLight.enabled = true; flashLightSwitch = 1; } else { flashLight.enabled = false; flashLightSwitch = 0; } } } public void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) { if(stream.IsWriting) { stream.SendNext(flashLightSwitch); } if(stream.IsReading) { flashLightSwitch = (int)stream.ReceiveNext(); } }
0