Shoot Delay added
This commit is contained in:
@@ -16,7 +16,10 @@ public class WeaponScript : MonoBehaviour
|
||||
|
||||
public float reloadTime;
|
||||
|
||||
public void reload(){
|
||||
private bool delayOver = true;
|
||||
public float schussInterval;
|
||||
private float delay = 0;
|
||||
public void checkReload(){
|
||||
if(ammo == 0){
|
||||
isReloading = true;
|
||||
}
|
||||
@@ -31,17 +34,25 @@ public class WeaponScript : MonoBehaviour
|
||||
}
|
||||
public void shoot(){
|
||||
if(ammo != 0){
|
||||
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
||||
muzzle.gameObject.SetActive(true);
|
||||
//muzzle.Play();
|
||||
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
|
||||
ammo--;
|
||||
}
|
||||
}else{
|
||||
reload();
|
||||
if(delayOver){
|
||||
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
||||
muzzle.gameObject.SetActive(true);
|
||||
//muzzle.Play();
|
||||
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
|
||||
ammo--;
|
||||
delay = 0;
|
||||
delayOver = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void checkDelay(){
|
||||
if(!delayOver){
|
||||
delay += Time.deltaTime;
|
||||
if(delay > schussInterval){
|
||||
delayOver = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
@@ -53,7 +64,8 @@ public class WeaponScript : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
checkDelay();
|
||||
shoot();
|
||||
checkReload();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user