Skip to content

Instantly share code, notes, and snippets.

@xSystemIOx
Last active May 9, 2018 16:02
Show Gist options
  • Select an option

  • Save xSystemIOx/6a29339d5470a2be4352e95f0379525c to your computer and use it in GitHub Desktop.

Select an option

Save xSystemIOx/6a29339d5470a2be4352e95f0379525c to your computer and use it in GitHub Desktop.
Fires a projectile in 2D
void Update () {
if (contact == true) {
if (Input.GetButtonDown ("Fire1")) {
Vector3 layer = new Vector3 (launchPoint.transform.position.x , launchPoint.transform.position.y , 10f);
GameObject go = (GameObject)Instantiate (shot,layer, Quaternion.identity);
go.GetComponent <Rigidbody2D> ().velocity = new Vector2 (velocity.x * (transform.position.x + 6), velocity.y);
Instantiate (recoilParticle, launchPoint.transform.position, Quaternion.identity);
SD.Play ();
shake = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment