- Home /
Unity Network HTC Vive and Oculus
Hi. I want to sync the position of some objects with the Vive/Oculus Controllers position. In the end I want to see the Vive controllers from Oculus and Oculus controllers from Vive.
What i did until now:
If Vive is the server: From Oculus i see the Vive models moving and everything is fine, but from Vive i can't see the Oculus controllers moving.
If Oculus is the server: From Vive i see the Oculus models moving, but form Oculus i can't see the Vive controllers moving.
Implementation:
I have 4 prefabs:
Vive controller left
Vive controller right
Oculus controller left
Oculus controller right
All have network identity: local player authority and network transform
Next script is on the player:
void Update()
{
if (!isLocalPlayer)
{
return;
}
if (IsVive())
{
CmdControllerPositionSyncVive();
}
else if (IsOculus())
{
CmdControllerPositionSyncOculus();
}
}
[Command]
public void CmdControllerPositionSyncVive()
{
if (_leftControllerSource != null && _viveControllerLeft != null)
{
SetViveAvatar();
_viveControllerLeft.transform.position = _leftControllerSource.transform.position;
_viveControllerLeft.transform.rotation = _leftControllerSource.transform.rotation;
}
if (_rightControllerSource != null && _viveControllerRight != null)
{
SetViveAvatar();
_viveControllerRight.transform.position = _rightControllerSource.transform.position;
_viveControllerRight.transform.rotation = _rightControllerSource.transform.rotation;
}
}
[Command]
public void CmdControllerPositionSyncOculus()
{
if (_leftControllerSource != null && _oculusControllerLeft != null)
{
SetOculusAvatar();
_oculusControllerLeft.transform.position = _leftControllerSource.transform.position;
_oculusControllerLeft.transform.rotation = _leftControllerSource.transform.rotation;
}
if (_rightControllerSource != null && _oculusControllerRight != null)
{
SetOculusAvatar();
_oculusControllerRight.transform.position = _rightControllerSource.transform.position;
_oculusControllerRight.transform.rotation = _rightControllerSource.transform.rotation;
}
}
I'm beginner so if you have some ideas about what's happening here, please help. I think that the server don't sent data to client, but i'm not sure and i don't know how to do it. I've tried with [ClientRpc] but it didn't work.
Your answer
Follow this Question
Related Questions
Instantiation of HTC Vives CameraRig using Photon, client is moving other client's CameraRig 0 Answers
Different movement speeds over network 1 Answer
Unity 5.1 VR Oculus 1 Answer
Network command is running on client? 1 Answer
Trying to send command for object without authority. - change color of object from client 0 Answers