Advertisement
lemansky

Untitled

Apr 4th, 2021
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Blaster : MonoBehaviour
  6. {
  7.  
  8.     public float fireRate = 0.5f;
  9.     public float fireCooldown = -1f;
  10.     public GameObject bulletPrefab;
  11.  
  12.     void Update()
  13.     {
  14.         if (Input.GetMouseButtonDown(0) && Time.time > fireCooldown)
  15.         {
  16.             fireCooldown = Time.time + fireRate;
  17.             Instantiate(bulletPrefab, transform.position, transform.rotation);
  18.         }
  19.     }
  20.  
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement