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

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); 
    } 
主站蜘蛛池模板: 天津市| 名山县| 宿松县| 天水市| 巧家县| 昌黎县| 扶余县| 朝阳县| 家居| 仪陇县| 麻城市| 堆龙德庆县| 凤台县| 乌兰察布市| 会宁县| 德兴市| 大方县| 即墨市| 巨鹿县| 临西县| 绥德县| 梓潼县| 乌兰察布市| 濮阳县| 保康县| 东乡族自治县| 正宁县| 上饶县| 阳泉市| 库车县| 定安县| 郸城县| 满城县| 姚安县| 鱼台县| 海林市| 阿图什市| 綦江县| 庄河市| 东乡| 波密县|