91.打砖块项目相关技术总结

7527152-fc88b57da5d13e10.png
aaa.png
1.鼠标左键
  if(Input.GetMouseButtonDown(0))
        {
            Debug.Log("press");
            GameObject bullet1 = GameObject.Instantiate(bullet,transform.position,transform.rotation);
            Rigidbody rgd = bullet1.GetComponent<Rigidbody>();
            rgd.velocity = transform.forward * speed;
        }

2.键盘上下左右的控制、球初速度的生成
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical"); //键盘上下左右的控制
        transform.Translate(new Vector3(h,v,0) * Time.deltaTime * 20);//球初速度的生成

猜你喜欢

转载自blog.csdn.net/weixin_33924220/article/details/87132024