/// <summary> /// MoveController 摇杆输入 /// MobaMeSync 网络输入 /// 两个综合考虑 /// </summary> /// <returns></returns> public override IEnumerator RunLogic() { networkMove = GetAttr().GetComponent <ISyncInterface>(); var physics = GetAttr().GetComponent <CreepMeleeAI>(); while (!quit) { var curInfo = networkMove.GetServerVelocity(); var isNetMove = MobaUtil.IsServerMove(curInfo); if (isNetMove) { if (isNetMove)//依赖服务器寻路 { MoveByNet(); } yield return(null); } else { break; } } if (!quit) { aiCharacter.ChangeState(AIStateEnum.IDLE); } }
public static bool IsServerMoveBySpeedOrPos(ISyncInterface sync) { var speed = sync.GetServerVelocity(); if (IsServerMove(speed)) { return(true); } var pos = sync.GetServerPos(); var posDelta = IsNetMove(pos, sync.transform.position); return(posDelta); }
/// <summary> /// MoveController 摇杆输入 /// MobaMeSync 网络输入 /// 两个综合考虑 /// </summary> /// <returns></returns> public override IEnumerator RunLogic() { networkMove = GetAttr().GetComponent <ISyncInterface>(); var physics = GetAttr().GetComponent <CreepMeleeAI>(); while (!quit) { //var curInfo = networkMove.GetServerVelocity(); var isLocalMove = MobaUtil.IsLocalMove(vcontroller); var isNetMove = MobaUtil.IsServerMoveBySpeedOrPos(networkMove); if (isLocalMove || isNetMove) { if (isNetMove)//依赖服务器寻路 { //MoveByNet(); //多个服务器发过来的帧率 有可能导致预测失败 现在的位置超过了预测位置导致玩家不断回头 //yield return GetAttr().StartCoroutine(MoveSmooth()); MoveByNet(); yield return(new WaitForFixedUpdate()); } else if (isLocalMove) //依赖本地的寻路 { MoveByHand(); yield return(new WaitForFixedUpdate()); } } else { break; } } if (!quit) { aiCharacter.ChangeState(AIStateEnum.IDLE); } }
public override void Init() { base.Init(); sync = aiCharacter.GetAttr().GetComponent <ISyncInterface>(); }