public GameObject bullet; // Update is called once per frame void Update () { if(Input.GetMouseButtonDown(0)) { shot(); } } void shot() { Instantiate(bullet, transform.position, transform.rotation); }
ちなみに、弾の方のスクリプトは以下。
public int speed = 10; Rigidbody rb; // Use this for initialization void Start () { rb = GetComponent<Rigidbody>(); rb.velocity = transform.up.normalized * speed; }