- 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); }
推薦閱讀
- Application Development with Qt Creator(Second Edition)
- 從區(qū)塊鏈到Web3:構(gòu)建未來(lái)互聯(lián)網(wǎng)生態(tài)
- 網(wǎng)絡(luò)故障現(xiàn)場(chǎng)處理實(shí)踐(第4版)
- Learning QGIS 2.0
- Web Application Development with R Using Shiny
- 互聯(lián)網(wǎng)安全的40個(gè)智慧洞見:2015年中國(guó)互聯(lián)網(wǎng)安全大會(huì)文集
- 企業(yè)網(wǎng)絡(luò)安全管理
- 城市治理一網(wǎng)統(tǒng)管
- 物聯(lián)網(wǎng)之霧:基于霧計(jì)算的智能硬件快速反應(yīng)與安全控制
- 紅藍(lán)攻防:構(gòu)建實(shí)戰(zhàn)化網(wǎng)絡(luò)安全防御體系
- 端到端QoS網(wǎng)絡(luò)設(shè)計(jì)
- Learning Storm
- 5G+區(qū)塊鏈
- 深入理解計(jì)算機(jī)網(wǎng)絡(luò)
- 物聯(lián)網(wǎng)與智慧廣電