Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public abstract class Gun : MonoBehaviour
- {
- protected float coolDown;
- protected bool auto;
- protected float speed;
- protected int damage;
- private float timer;
- [SerializeField]
- protected GameObject bullet;
- [SerializeField]
- protected GameObject riffleStart;
- public void Shoot()
- {
- if (Input.GetMouseButtonDown(0) || auto)
- {
- if (timer > coolDown)
- {
- OnShoot();
- timer = 0;
- }
- }
- }
- private void Update()
- {
- timer += Time.deltaTime;
- }
- protected virtual void OnShoot() { }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement