《打砖块》教程知识梳理

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class shoot : MonoBehaviour {

public GameObject bullet;
public float speed = 5;
private float time = 0;
private float timer = 3;
public GameObject b;
// Use this for initialization
void Start () {
Debug.Log("--Hellow Unity!");
// GameObject.Instantiate(bullet,transform.position,transform.rotation);
}

// Update is called once per frame
void Update () {

if(Input.GetMouseButtonDown(0))
{

b = GameObject.Instantiate(bullet, transform.position, transform.rotation);
Rigidbody rgd = b.GetComponent<Rigidbody>();
rgd.velocity = transform.forward * speed;


}

}
}

上一篇:(二) GameObject物体的创建, 渲染和基本操作


下一篇:Unity学习日志