Advertisement
kadyr

Untitled

Oct 16th, 2021
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public abstract class Gun : MonoBehaviour
  4. {
  5. protected float coolDown;
  6. protected bool auto;
  7. protected float speed;
  8. protected int damage;
  9.  
  10. private float timer;
  11.  
  12. [SerializeField]
  13. protected GameObject bullet;
  14.  
  15. [SerializeField]
  16. protected GameObject riffleStart;
  17. public void Shoot()
  18. {
  19. if (Input.GetMouseButtonDown(0) || auto)
  20. {
  21. if (timer > coolDown)
  22. {
  23. OnShoot();
  24. timer = 0;
  25. }
  26. }
  27. }
  28.  
  29. private void Update()
  30. {
  31. timer += Time.deltaTime;
  32. }
  33.  
  34. protected virtual void OnShoot() { }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement