This commit is contained in:
Gerard Gascón 2025-04-24 14:23:29 +02:00
commit bd5b1556ff
269 changed files with 6249829 additions and 0 deletions

26
Assets/Scripts/Shoot.cs Normal file
View file

@ -0,0 +1,26 @@
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;
}
}
}