void LateUpdate() { //try { if (zmq != null) { if (zmq.getNewestData(out output)) { //Expect righthand, X front, Z up coordinate system m_position = CoordinateTransformations.VectorToGameEngine(new Vector3(output.px, output.py, output.pz)); m_rotation = CoordinateTransformations.QuaternionToGameEngine(new Quaternion(output.qx, output.qy, output.qz, output.qw)); //update height if walking on ground if (WalkOnGround) { //trace from new x,z coordinates and old height, with height = new height m_position = FallToGround(m_position, m_position.y); } } } transform.position = m_position; transform.rotation = m_rotation; //trigger position update TriggerPositionUpdate(m_position, m_rotation); }
void doUpdate() { //try { if (zmq != null) { if (zmq.getNewestData(out output)) { //Expect righthand, X front, Z up coordinate system pos = CoordinateTransformations.VectorToGameEngine(new Vector3(output.px, output.py, output.pz)); ori = CoordinateTransformations.QuaternionToGameEngine(new Quaternion(output.qx, output.qy, output.qz, output.qw)); m_rotation = ori; //update height if walking on ground if (WalkOnGround) { //trace from new x,z coordinates and old height, with height = new height m_position = FallToGround(new Vector3(pos.x, m_position.y, pos.z), pos.y); } else { m_position = pos; } } Invoke("doUpdate", updateTime); } else { Invoke("doUpdate", 1f); } //trigger position update TriggerPositionUpdate(m_position, m_rotation); }