示例#1
0
        private Quaternion syncCmdDir; //同步命令的方向
        /// <summary>
        /// 同步位置
        /// </summary>
        /// <param name="posSyncDTO"></param>
        public void PosSync(Vector3 pos, Vector3 dir, long syncSendTimeStamp)
        {
            this.isMoving = true;
            float lerpTime = GameRuntimeData.delayAndFloating.delay * 4;

            this.arriveTime = (syncSendTimeStamp + lerpTime) * 0.0000001f - GameRuntimeData.FloatingBwteenDatatimeAndUnityTime;
            //1.计算出期望的位置,方向
            wantedPos = MoveHelper.GetFuturePos(pos, dir, lerpTime, soilderDriver.Speed);
            wantedDir = Quaternion.Euler(dir);
            //3.记录现在的时间、位置、方向,将这个时间转化为以Time.time为准
            syncCmdTime = Time.time;
            syncCmdPos  = transform.position;
            syncCmdDir  = transform.rotation;

            if (soilderDriver != null)
            {
                soilderDriver.Move();
            }
        }
示例#2
0
 /// <summary>
 /// 当前位置和推测位置的距离
 /// </summary>
 /// <param name="curPos"></param>
 /// <param name="lastSendPos"></param>
 /// <param name="lastSendDir"></param>
 /// <param name="timeEscaped"></param>
 /// <param name="speed"></param>
 /// <returns></returns>
 private float DistanceBetweenCurPosAndPredict(Vector3 curPos, Vector3 lastSendPos, Vector3 lastSendDir, float timeEscaped, float speed)
 {
     return(Vector3.Distance(curPos, MoveHelper.GetFuturePos(lastSendPos, lastSendDir, timeEscaped, speed)));
 }