Exemplo n.º 1
0
        void UnserializeModeTransform(NetworkReader reader, bool initialState)
        {
            if (hasAuthority)
            {
                // this component must read the data that the server wrote, even if it ignores it.
                // otherwise the NetworkReader stream will still contain that data for the next component.

                // position
                reader.ReadVector3();

                if (syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
                }
                return;
            }

            if (isServer && m_ClientMoveCallback3D != null)
            {
                var pos = reader.ReadVector3();
                var vel = Vector3.zero;
                var rot = Quaternion.identity;
                if (syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    rot = NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
                }

                if (m_ClientMoveCallback3D(ref pos, ref vel, ref rot))
                {
                    m_TargetSyncPosition = pos;
                    if (syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                    {
                        m_TargetSyncRotation3D = rot;
                    }
                }
                else
                {
                    // rejected by callback
                    return;
                }
            }
            else
            {
                // position
                m_TargetSyncPosition = reader.ReadVector3();

                // rotation
                if (syncRotationAxis != NetworkTransform.AxisSyncMode.None)
                {
                    m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
                }
            }
        }
Exemplo n.º 2
0
 private void UnserializeModeTransform(NetworkReader reader, bool initialState)
 {
     if (base.hasAuthority)
     {
         reader.ReadVector3();
         if (syncRotationAxis != 0)
         {
             NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
         }
     }
     else if (base.isServer && m_ClientMoveCallback3D != null)
     {
         Vector3    position = reader.ReadVector3();
         Vector3    velocity = Vector3.zero;
         Quaternion rotation = Quaternion.identity;
         if (syncRotationAxis != 0)
         {
             rotation = NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
         }
         if (m_ClientMoveCallback3D(ref position, ref velocity, ref rotation))
         {
             m_TargetSyncPosition = position;
             if (syncRotationAxis != 0)
             {
                 m_TargetSyncRotation3D = rotation;
             }
         }
     }
     else
     {
         m_TargetSyncPosition = reader.ReadVector3();
         if (syncRotationAxis != 0)
         {
             m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, syncRotationAxis, rotationSyncCompression);
         }
     }
 }