//点击按键,生成子弹,并射向前方 void ShootBullet() { if (Input.GetMouseButtonDown(0)) { GameObject temp_Buller = GameObject.Instantiate(bulletPrefab, new Vector3(playerTransform.position.x, playerTransform.position.y, playerTransform.position.z + 0.37f), Quaternion.identity); temp_Buller.GetComponent<Rigidbody>().velocity = Vector3.forward * bulletSpeed; } }
Input.GetMouseButtonDown(1)
0是鼠标左键
1是鼠标右键
2是鼠标滑轮按键