// Update is called once per frame public void Update() { if (MiddleVR.VRClusterMgr.IsClient() && m_STScript != null) { if (m_tracker == null && MiddleVR.VRDeviceMgr != null) { m_tracker = MiddleVR.VRDeviceMgr.GetTracker(m_STScript.ShareName); MiddleVRTools.Log("[+] Acquired shared tracker " + m_tracker.GetName()); } if (m_tracker != null) { // Get rid of anything that could move the object //Destroy(rigidbody); vrVec3 pos = m_tracker.GetPosition(); vrQuat or = m_tracker.GetOrientation(); Vector3 p = new Vector3(pos.x(), pos.y(), pos.z()); Quaternion q = new Quaternion((float)or.x(), (float)or.y(), (float)or.z(), (float)or.w()); transform.position = p; transform.rotation = q; //MiddleVRTools.Log("Client applying data : " + p.z ); } } }
// On clients, handle the command call private vrValue _CommandHandler(vrValue iValue) { if (m_ClusterMgr.IsClient()) { // extract position and orientation from the vrValue vrVec3 pos = iValue[0].GetVec3(); vrQuat orient = iValue[1].GetQuat(); Vector3 p = new Vector3(pos.x(), pos.y(), pos.z()); Quaternion q = new Quaternion(orient.x(), orient.y(), orient.z(), orient.w()); transform.position = p; transform.rotation = q; } return(null); }