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

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); 
    } 
主站蜘蛛池模板: 金溪县| 通化市| 克什克腾旗| 城口县| 南投县| 浦城县| 临朐县| 城固县| 城市| 前郭尔| 凤翔县| 黔西县| 宁陕县| 渭源县| 金寨县| 禄丰县| 冷水江市| 上思县| 永川市| 襄垣县| 营山县| 运城市| 巫溪县| 南充市| 镇坪县| 光山县| 虞城县| 廉江市| 福州市| 阿坝| 防城港市| 聂拉木县| 砚山县| 汉寿县| 田东县| 临武县| 馆陶县| 凯里市| 饶阳县| 布拖县| 义乌市|