Esempio n. 1
0
        /// <summary>
        /// NetowrkIdendtity経由でデータを送ってもらう
        /// </summary>
        /// <param name="packet"></param>
        internal void OnRecieveSyncTransformPacket(ushort senderPlayerId, ref DataStreamReader packet, ref DataStreamReader.Context ctx)
        {
            if (CacheRecordableIdentity.hasAuthority)
            {
                return;
            }

            var progressTime   = packet.ReadUInt(ref ctx);
            var position       = packet.ReadVector3(ref ctx);
            var rotation       = packet.ReadQuaternion(ref ctx);
            var velocity       = packet.ReadVector3(ref ctx);
            var anglerVelocity = packet.ReadVector3(ref ctx);

            //受信パケットに記録した時間が古いものなら使わない.
            if (progressTime < prevReceiveTime)
            {
                Debug.Log("eject");
                return;
            }

            //Rigidbodyの値はすぐに適用
            if (CacheRigidbody != null)
            {
                CacheRigidbody.velocity        = velocity;
                CacheRigidbody.angularVelocity = anglerVelocity;
            }

            prevReceiveTime    = progressTime;
            recPosition        = position;
            recRotation        = rotation;
            recVelocity        = velocity;
            recvAnglerVelicity = anglerVelocity;
            //Debug.Log ("OnRecieveSyncTransformPacket");
        }
Esempio n. 2
0
        protected override Parameters DeserializeParams(ref DataStreamReader reader)
        {
            Vector3    muzzlePosition    = reader.ReadVector3();
            Quaternion muzzleOrientation = reader.ReadQuaternion();

            return(new Parameters(muzzlePosition, muzzleOrientation));
        }
Esempio n. 3
0
        protected override void Deserialize(ref DataStreamReader reader, byte dirtyMask)
        {
            var mask = (DirtyMask)dirtyMask;

            if (mask != 0)
            {
                _lastUpdateTime = reader.ReadFloat();
            }
            if (mask.HasFlag(DirtyMask.Position))
            {
                _latestPosition = reader.ReadVector3();
                _predictedPosition.ReceiveValue(_lastUpdateTime, _latestPosition);
            }

            if (mask.HasFlag(DirtyMask.Rotation))
            {
                _latestRotation = reader.ReadQuaternion();
                _predictedRotation.ReceiveValue(_lastUpdateTime, _latestRotation);
            }
        }