- Home /
Synchronization in Photon, I have a scene where I dont instantiate anything, but I want it to update its status constantly on all clients
Hi, I am further developing my game and basically I am having now a quite easy part to deal with. As aforementioned in the question title, I have a scene where there are no player objects to be instantiated. All clients are able to interact with the elements of the scene using the GUI Buttons and when one client pushes a button, I want the update to be smoothly synchronized on all clients. I have added a Photon View Script to the elements I want synchronized, still they start to behave strangely unaccordingly to the physics system ( for example, on one client screen they start floating and bouncing irregularly, whereas on the screen of the client that gave the input from buttons, everything goes as expected.
I have made some research, but I am afraid it would help mostly in the case where I had multiple players objects which is not here the case I suppose. Has my problem anything to do with my camera, or with my network stream?
Please, take into account everything I have mentioned and should you have any other further question, ask here. Any tips, links, even scripts!! are welcome!
Well i need more information like scripts and thinks. I might be of help if you provide scripts and screenshots of your photon views because i am currently using photon view myself but i need more information.
Also are you using RPC calls when doing actions like moving or destroying something?
also what component is the photonview observing?
using UnityEngine; using System.Collections;
public class Network$$anonymous$$anager : $$anonymous$$onoBehaviour {
const string VERSION="v0.0.1";
public string roomName="$$anonymous$$yRoom";
public string playerPrefabName="Interactable Object";
public Transform spawnPoint;
void Start () {
PhotonNetwork.ConnectUsingSettings (VERSION);
}
void OnJoinedLobby()
{
RoomOptions roomOptions = new RoomOptions (){ IsVisible = false, $$anonymous$$axPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom (roomName, roomOptions, TypedLobby.Default);
}
void OnJoinedRoom()
{
Debug.Log ("It has entered");
}
void OnJoinedFailedRoom()
{
Debug.Log ("It has not");
}
void OnGUI()
{
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}
}
The photonview is viewing all the objects that are supposed to be affected by the input from the buttons. For example, supposing I have a cube object in the scene and by pressing the button, I would like it to execute a jump. The same jump should be visible smoothly on all client objects, thing that unfortunatelyhas not happened yet.
Answer by SPOTNINJADUD7890 · Oct 09, 2016 at 05:02 PM
Well you need to use calls over the network in the functions that do the stuff you want to sync. aka RPC calls
Hey, I was wondering whether you could give me a brief script of a such RPC call for Photon, in the case of an AddForce function, where all the players could see when a cube gameobject gets knocked back whenever a client presses a button. I've studied the RPC calls and now I'm going to put them into practice.
I am sorry if I bothered you with so many questions, but Photon is such a large topic for me at the beginning.
all you have to do it have the photonview observe the transform :D
thank you for you advices, they really proved useful!:)