Unity Input.GetMouseButtonDown 拿到鼠标按键

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

posted @ 2017-08-27 19:27  朋丶Peng  阅读(1789)  评论(0编辑  收藏  举报