init
This commit is contained in:
commit
bd5b1556ff
269 changed files with 6249829 additions and 0 deletions
26
Assets/Scripts/Shoot.cs
Normal file
26
Assets/Scripts/Shoot.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue