Created
May 9, 2018 14:26
-
-
Save xSystemIOx/cead2f0153f2326faeb2c4b53d16ba5c to your computer and use it in GitHub Desktop.
Instantiates and launches the projectile forward
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
| public class ProjectileShooter : MonoBehaviour { | |
| public float speed = 200f; | |
| public GameObject prefab; | |
| public void Shoot() | |
| { | |
| GameObject projectile = Instantiate (prefab,transform.position,Quaternion.identity ) as GameObject; | |
| projectile.transform.eulerAngles = transform.eulerAngles; | |
| Rigidbody rb = projectile.GetComponent<Rigidbody>(); | |
| rb.velocity = transform.forward * speed; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment