Beispiel #1
0
        /// <summary>
        /// Update the look variables of the camera. This is sent to all of the other clients so the clients can accurately update the character's IK.
        /// </summary>
        private void Update()
        {
            var lookRay = m_TargetLookRay.Get();

            // The server only needs to know the look position when the character is aiming. Don't sync every frame because that would cause too much bandwidth.
            if (m_LastSyncTime + m_NetworkTransform.GetNetworkSendInterval() < Time.time)
            {
                CmdUpdateCameraVariables(lookRay.origin, lookRay.direction, m_LookDistance.Get(), m_Recoil.Get());
                var targetLock = m_TargetLock.Get();
                if (m_CameraTargetLock != targetLock)
                {
                    CmdUpdateCameraTargetLock(targetLock != null ? targetLock.gameObject : null);
                    m_CameraTargetLock = targetLock;
                }
                m_LastSyncTime = Time.time;
            }
            // Update the camera variables immediately on the local machine. There is no reason to wait for the server to update these variables.
            UpdateCameraVariables(lookRay.origin, lookRay.direction, m_LookDistance.Get(), m_Recoil.Get());
        }