- Unity Artificial Intelligence Programming
- Dr. Davide Aversa Aung Sithu Kyaw Clifford Peters
- 88字
- 2021-06-10 18:57:49
Shooting bullet
Whenever the player clicks the left mouse button, we check whether the total elapsed time since the last fire has passed the fire rate of the weapon. If it has, then we create a new Bullet object at the SpawnPoint variable's position. In this way, we can prevent the player from shooting a continuous stream of bullets:
void UpdateWeapon() { if (Input.GetMouseButtonDown(0)) { elapsedTime += Time.deltaTime; if (elapsedTime >= shootRate) { //Reset the time elapsedTime = 0.0f; //Instantiate the bullet Instantiate(Bullet, bulletSpawnPoint.position, bulletSpawnPoint.rotation); } } }
推薦閱讀
- 信息通信網絡建設安全管理概要2
- Getting Started with WebRTC
- Wireshark網絡分析就這么簡單
- Mastering JavaFX 10
- 物聯網之霧:基于霧計算的智能硬件快速反應與安全控制
- C/C++串口通信:典型應用實例編程實踐
- 通信原理及MATLAB/Simulink仿真
- 面向5G-Advanced的關鍵技術
- 4G小基站系統原理、組網及應用
- 網絡利他行為研究:積極心理學的視角
- 組網技術與網絡管理
- 互聯網安全的40個智慧洞見(2016)
- Dart Cookbook
- 精通SEO:100%網站流量提升密碼
- Hands-On Docker for Microservices with Python