hey all,
I’m working on a multiplayer VR application.
the goal is to pickup object in VR using the HTC Vive, this is working without a problem by using the SteamVR assets. the problem is however when one player pickup a item the item is set as a child to the local VR player which doesn’t exist on the other players sides. Because the transform of the item is now local to the SteamVR Controller the transform of the item is local. the photon transform view does sync the position but only the local position.
now i’m wondering if it is possible to make photon synchronize the worldspace position of a transform instead of the localspace position.
thanks in advance!
Tim
ps: apologies if this is in the wrong section, didn’t know for sure if here or in the VR section would be best
If you use OnPhotonSerializeView you should be able to synchronize whatever you want.
This may be old but in my experience the PhotonTransformView syncs the world position, you can look it up in the code: stream.SendNext(transform.position);
And the PhotonTransformViewClassic is using the locaPosition:
this.m_PositionControl.OnPhotonSerializeView(transform.localPosition, stream, info);
from the PhotonTransformView.cs source code it seems to sync localPosition too:
if (this.m_SynchronizeRotation)
{
stream.SendNext(transform.localRotation);
}
if (this.m_SynchronizeScale)
{
stream.SendNext(transform.localScale);
}
so I’ve added a new property
public bool m_SynchronizeGlobal = false;
and updated the OnPhotonSerializeView to use global when this glad is set to true.
You also want to update editor PhotonTransformViewEditor
to have this option editable:
view.m_SynchronizeGlobal = EditorGUILayout.ToggleLeft(" Use global values", view.m_SynchronizeGlobal);
This changed recently in PUN 2.20. The PhotonTransformView (the newer one) is now also using LocalPosition. In v2.19 and older, it sent world positions.
Really good to know
Though I need to change it back which is no problem. But let me tell you my use-case:
I have a player controller (FPS) that receives the input and lets the player walk around. I did not have any avatars before implementing multiplayer so the easiest way was to instantiate the avatar 3D-model in the scene and if it was “mine”, then parent it under the player controller. So every player has its avatar under the controller but for the other players it is sitting in the scene without a parent.
So moving around also moves the avatar for the local player and the position of the avatar is synced to the fitting avatar on the other clients. But since the local avatar is parented the local position is not the local position of the remote avatars.
So a simple flag like yoda mentioned would be nice in one of the next updates, but no hurry 
1 Like