Last active
May 9, 2018 16:02
-
-
Save xSystemIOx/6a29339d5470a2be4352e95f0379525c to your computer and use it in GitHub Desktop.
Fires a projectile in 2D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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