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

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); 
    } 
主站蜘蛛池模板: 普格县| 常宁市| 惠安县| 苏尼特左旗| 宁陕县| 林芝县| 鲁甸县| 砀山县| 依兰县| 秦皇岛市| 江安县| 安溪县| 贵南县| 天津市| 呼伦贝尔市| 怀安县| 荣昌县| 湟中县| 丹寨县| 沾益县| 于都县| 汾西县| 九龙坡区| 福州市| 和政县| 苏尼特左旗| 姚安县| 府谷县| 三原县| 开原市| 陆川县| 城固县| 罗田县| 南郑县| 盐源县| 兴宁市| 万安县| 宁波市| 新闻| 额尔古纳市| 清河县|