Example #1
0
        /// <summary>
        /// Sends packets to peers.
        /// Takes events regarding incoming packets and handles them.
        /// </summary>
        private void Update()
        {
            manager.PollEvents();

            SetPacketRotation();
            SetPacketPosition();

            BuildDebug.Log("Raw Vector: ", Input.compass.rawVector);
            BuildDebug.Log("Gyro: ", Input.gyro.attitude.eulerAngles);
            BuildDebug.Log("Compass magnetic: ", Input.compass.magneticHeading);
            BuildDebug.Log("Compass true: ", Input.compass.trueHeading);
            BuildDebug.Log("Compass accuracy: ", Input.compass.headingAccuracy);

            var peer = manager.FirstPeer;

            if (peer == null || peer.ConnectionState != ConnectionState.Connected)
            {
                discoveryTimer += Time.deltaTime;

                if (discoveryTimer > 2f)
                {
                    SendAndResetDiscoveryRequest();
                }
                return;
            }

            SendPacketSerializable(PacketType.Transform, transformPacket, DeliveryMethod.Unreliable);
        }
Example #2
0
        /// <summary>
        /// Sets the position to send in the packet, calculates the positional difference from the anchor to the client and sends.
        /// </summary>
        private void SetPacketPosition()
        {
            Vector3 localDiff = CompassAlignedScene.instance.alignedLocalPeer.transform.localPosition - CompassAlignedScene.instance.alignedAnchor.transform.localPosition;

            transformPacket.position = localDiff;
            BuildDebug.Log("Sent Packet: ", transformPacket.position);
        }
Example #3
0
 /// <summary>
 /// Updates the transform of the aligned anchor according to the original anchor.
 /// </summary>
 private void UpdateAlignAnchor()
 {
     if (anchor != null)
     {
         alignedAnchor.transform.position = anchor.transform.position;
         BuildDebug.Log("Anchor World Pos: ", alignedAnchor.transform.position);
         BuildDebug.Log("Anchor Align Pos: ", alignedAnchor.transform.localPosition);
     }
 }
Example #4
0
 /// <summary>
 /// Updates the transform of the aligned local peer according to the original local peer.
 /// </summary>
 private void UpdateAlignLocalPeer()
 {
     if (localPeer != null)
     {
         alignedLocalPeer.transform.SetPositionAndRotation(localPeer.transform.position, localPeer.transform.rotation);
         BuildDebug.Log("Local World Pos: ", alignedLocalPeer.transform.position);
         BuildDebug.Log("CliLocalent Align Pos: ", alignedLocalPeer.transform.localPosition);
     }
 }
Example #5
0
        private void Update()
        {
            BuildDebug.Log("Start Compass: "******"Diff World Peer - Anchor: ", (alignedLocalPeer.transform.position - alignedAnchor.transform.position));
            BuildDebug.Log("Diff Align Peer - Anchor: ", (alignedLocalPeer.transform.localPosition - alignedAnchor.transform.localPosition));
        }
Example #6
0
 private void Awake()
 {
     instance = this;
 }