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