private void BroadcastMotionToRelevantPlayers() { if (m_RelChecker.RelevantTo.Count == 0) { return; } if (!CompressRotation) { var msg = new MotionMessage { Pos = m_LastPos, Rot = m_LastRot, TargetNetID = netId }; foreach (var nc in m_RelChecker.RelevantTo) { nc.Send(MessageType.Motion, msg); } } else { var msg = new CompressedMotionMessage { Pos = m_LastPos, RotX = (short)m_LastRot.eulerAngles.x, RotY = (short)m_LastRot.eulerAngles.y, RotZ = (short)m_LastRot.eulerAngles.z, TargetNetID = netId }; foreach (var nc in m_RelChecker.RelevantTo) { nc.Send(MessageType.CompressedMotion, msg); } } }
public void ReceiveCompressedMotionMessage(CompressedMotionMessage msg) { m_SyncPos = msg.Pos; m_SyncRot = Quaternion.identity; m_SyncRot.eulerAngles = new Vector3(msg.RotX, msg.RotY, msg.RotZ); }