Shoot Delay added
This commit is contained in:
parent
0c1f0a5d87
commit
1d2e0fa470
@ -503,6 +503,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 5950832400214244271}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1169450665700565, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
|
||||
propertyPath: schussInterval
|
||||
value: 0.3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 686265786403669914, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0.499
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user