unity3d打砖块源码



*Shoot.cs
public class Shoot : MonoBehaviour {
    public GameObject bullet;
    public float speed=5;

// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
        if (Input.GetMouseButtonDown(0)) {
            GameObject b = GameObject.Instantiate(bullet, transform.position, transform.rotation);
            Rigidbody r = b.GetComponent();
            r.velocity = speed * transform.forward;//速度乘以时间=力
       
        }
}
}
*Move.cs
public class Move : MonoBehaviour {
    public float speed = 3;
// Use this for initialization
void Start () {

}

你可能感兴趣的:(unity3d打砖块源码)