Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class AutoShooter : MonoBehaviour
- {
- Bullet bulletPrefab;
- public int bulletsPerShoot = 1;
- public int magazineSize = 1; //how many time this weapon shoot before reloading
- public float totalSpreadAngle = 0f;
- public float fireRate = 0f; //shoot times per second
- public float reloadRate = 1f; //speed of reloading magazine
- Vector3 GunPosition { get => transform.position; }
- Vector3 MuzzlePosition { get => transform.position }
- public void ShootBullet(object sender, Vector3 direction)
- {
- BulletBase newBullet = bulletPrefab;
- Instantiate(bulletPrefab, MuzzlePosition, Quaternion.identity);
- newBullet.Setup(direction); //bullet will fly toward direction
- }
- }
Add Comment
Please, Sign In to add comment