Skip to content

Instantly share code, notes, and snippets.

@xSystemIOx
Created May 9, 2018 14:26
Show Gist options
  • Select an option

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

Select an option

Save xSystemIOx/cead2f0153f2326faeb2c4b53d16ba5c to your computer and use it in GitHub Desktop.
Instantiates and launches the projectile forward
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