官术网_书友最值得收藏!

The Chase state

Similarly, while the tank is in the Chase state, it checks its distance with the player tank. If it's close enough, it'll switch to the Attack state. If the player tank has gone too far, then it'll go back to the Patrol state:

    protected void UpdateChaseState() 
    { 
      //Set the target position as the player position 
      destPos = playerTransform.position; 
 
      //Check the distance with player tank When 
      //the distance is near, transition to attack state 
      float dist = Vector3.Distance(transform.position,  
      playerTransform.position); 
 
      if (dist <= 200.0f) 
      { 
        curState = FSMState.Attack; 
      } 
      //Go back to patrol is it become too far 
      else if (dist >= 300.0f) 
      { 
        curState = FSMState.Patrol; 
      } 
 
      //Go Forward 
      transform.Translate(Vector3.forward * Time.deltaTime *  
      curSpeed); 
    } 
主站蜘蛛池模板: 启东市| 平罗县| 清丰县| 伊宁县| 苏尼特左旗| 前郭尔| 察哈| 福海县| 丽江市| 安康市| 周口市| 宾川县| 盖州市| 石城县| 工布江达县| 顺昌县| 临夏县| 思茅市| 会泽县| 当雄县| 体育| 太谷县| 岱山县| 湛江市| 潼关县| 理塘县| 洛扎县| 冕宁县| 鲁山县| 淳安县| 鄂托克旗| 嫩江县| 余干县| 安新县| 房产| 平江县| 连江县| 卢湾区| 家居| 洛阳市| 静乐县|