Skip to content

Instantly share code, notes, and snippets.

@yjsoon
Last active April 7, 2017 09:48
Show Gist options
  • Save yjsoon/8ca80800e4ffa367def950abaa058958 to your computer and use it in GitHub Desktop.
Save yjsoon/8ca80800e4ffa367def950abaa058958 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShooterScript : MonoBehaviour {
public Transform bulletTransform;
public Rigidbody bulletTemplate;
public float bulletSpeedX = -1000.0f;
// Use this for initialization
void Start () {
InvokeRepeating ("GenerateBullet", 0, 1);
}
// Update is called once per frame
void Update () {
}
void GenerateBullet() {
Quaternion rot = transform.rotation;
Rigidbody generatedBall = (Rigidbody)Instantiate (bulletTemplate, bulletTransform, rot);
generatedBall.AddForce (new Vector3 (bulletSpeedX, 0, 0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment