- Unity Artificial Intelligence Programming
- Dr. Davide Aversa Aung Sithu Kyaw Clifford Peters
- 98字
- 2021-06-10 18:57:50
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); }
推薦閱讀
- 社交網(wǎng)絡(luò)對齊
- Web安全防護指南:基礎(chǔ)篇
- 物聯(lián)網(wǎng)智慧安監(jiān)技術(shù)
- MERN Quick Start Guide
- 物聯(lián)網(wǎng)識別技術(shù)
- 光網(wǎng)絡(luò)評估及案例分析
- 異構(gòu)基因共表達網(wǎng)絡(luò)的分析方法
- Web Application Development with R Using Shiny
- Microsoft Dynamics CRM 2011 Applications(MB2-868) Certification Guide
- 精通SEO:100%網(wǎng)站流量提升密碼
- 深入理解計算機網(wǎng)絡(luò)
- 5G智慧交通
- 物聯(lián)網(wǎng)技術(shù)與實踐
- 黑客與反黑工具使用詳解
- Migrating to Drupal7