Hello,
My current game is using vrtk (VR ToolKit). I have this CameraRig game object, which is the player character. For some reasons, this CameraRig need to be on scene first instead of using PhotonNetwork.Instantiate function to spawn it. I cant get this CameraRig sync across the network.
What I've tried so far:
Attempt1: I have added photon view and network object component to the CameraRig. And set the CameraRig game object as the observed component in photon view component. Result: Player1 cant see Player2 (and vice versa)
Attempt2: I created another player prefab, when joined room. I use PhotonNetwork.Instantiate to spawn the player prefab.
void OnJoinedRoom() {
if (PhotonNetwork.isMasterClient) NewPlayer (0);
}
[PunRPC]
void NewPlayer(int idx) {
var trans = cameraRig.transform;
var player = PhotonNetwork.Instantiate (playerAvatar.name, trans.position, trans.rotation, 0);
player.name = "Player " + (idx + 1);
}
Now Player1 and Player2 can see each others. Then, in my Player prefab have this player setup script.
void Awake () {
if (!photonView.isMine) {
return;
}
GameObject g = GameObject.FindGameObjectWithTag("CameraRig");
g.transform.parent = transform;
}
I grab the CameraRig game object and set it as a child of the new player prefab thats instantiated by using PhotonNetwork.Instantiaite function. As expected, the CameraRig and its children game objects' position and rotation do not sync.
Given my current scenario above, how should I spawn / sync the players(CameraRig) game object ?
(Again, i need to emphasize this, the CameraRig game object needs to be on scene before the game connect to Photon server)
My CameraRig game object structure is something like this:
CameraRig
-- Ragdoll
-- Left Hand Controller
-- Right Hand Controller
-- Camera (head)
-- etc
Please advise. Thanks.
My current game is using vrtk (VR ToolKit). I have this CameraRig game object, which is the player character. For some reasons, this CameraRig need to be on scene first instead of using PhotonNetwork.Instantiate function to spawn it. I cant get this CameraRig sync across the network.
What I've tried so far:
Attempt1: I have added photon view and network object component to the CameraRig. And set the CameraRig game object as the observed component in photon view component. Result: Player1 cant see Player2 (and vice versa)
Attempt2: I created another player prefab, when joined room. I use PhotonNetwork.Instantiate to spawn the player prefab.
void OnJoinedRoom() {
if (PhotonNetwork.isMasterClient) NewPlayer (0);
}
[PunRPC]
void NewPlayer(int idx) {
var trans = cameraRig.transform;
var player = PhotonNetwork.Instantiate (playerAvatar.name, trans.position, trans.rotation, 0);
player.name = "Player " + (idx + 1);
}
Now Player1 and Player2 can see each others. Then, in my Player prefab have this player setup script.
void Awake () {
if (!photonView.isMine) {
return;
}
GameObject g = GameObject.FindGameObjectWithTag("CameraRig");
g.transform.parent = transform;
}
I grab the CameraRig game object and set it as a child of the new player prefab thats instantiated by using PhotonNetwork.Instantiaite function. As expected, the CameraRig and its children game objects' position and rotation do not sync.
Given my current scenario above, how should I spawn / sync the players(CameraRig) game object ?
(Again, i need to emphasize this, the CameraRig game object needs to be on scene before the game connect to Photon server)
My CameraRig game object structure is something like this:
CameraRig
-- Ragdoll
-- Left Hand Controller
-- Right Hand Controller
-- Camera (head)
-- etc
Please advise. Thanks.