//点击按键,生成子弹,并射向前方
    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是鼠标滑轮按键

相关文章:

  • 2022-02-08
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2021-08-13
  • 2022-01-22
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案