Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Fire() {
- if (asset.projectile == null) {
- Debug.Log("No projectile set up for gun part " + asset.dbName + "!");
- return;
- }
- for (int i = 0; i < asset.projectileQuantity; ++i) {
- var p = GameObject.Instantiate(asset.projectile);
- p.layer = gameObject.layer;
- // Align projectile with the barrel.
- // TODO: add scatter
- p.transform.position = turret.transform.position;
- p.transform.eulerAngles = barrel.transform.eulerAngles;
- var rbod = p.GetComponent<Rigidbody>();
- rbod.useGravity = asset.useGravity;
- rbod.AddRelativeForce(0, launchVelocity, 0, ForceMode.VelocityChange);
- var comp = p.AddComponent<Projectile>();
- comp.damage = asset.damage;
- comp.debug = (i == 0 && Time.renderedFrameCount == 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement