26 lines
669 B
C#
26 lines
669 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Shoot : MonoBehaviour{
|
|
|
|
public float timeBetweenShots;
|
|
public Transform firePoint;
|
|
public GameObject bullet;
|
|
|
|
float lastTimeShot;
|
|
float shotCounter;
|
|
|
|
public void Fire(){
|
|
if (Time.time > lastTimeShot + timeBetweenShots){
|
|
shotCounter -= Time.deltaTime;
|
|
if (shotCounter <= 0){
|
|
lastTimeShot = Time.time;
|
|
shotCounter = timeBetweenShots;
|
|
Instantiate(bullet, firePoint.position, firePoint.rotation);
|
|
}
|
|
}else{
|
|
shotCounter = 0;
|
|
}
|
|
}
|
|
}
|