Skip to content

Instantly share code, notes, and snippets.

@makoto-unity
Last active November 20, 2015 14:05
Show Gist options
  • Save makoto-unity/71b9023e990b9ab59c5a to your computer and use it in GitHub Desktop.
Save makoto-unity/71b9023e990b9ab59c5a to your computer and use it in GitHub Desktop.
#pragma strict
function Start () {
}
var bulletObj : GameObject;
function Update () {
if (Input.GetButtonDown("Fire1")) {
var go : GameObject = GameObject.Instantiate(bulletObj, this.transform.position, this.transform.rotation);
go.transform.position += this.transform.forward * 1.0f;
var rb : Rigidbody = go.AddComponent.<Rigidbody>();
rb.velocity = this.transform.forward * 10.0f;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment