- Home /
Question by
berkeseven42 · Jul 02, 2021 at 12:06 PM ·
codepage
I want to block GunFire,CrossAnimate,GunDamage Script while ı press R key to reload (until animation over)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReloadMechanic : MonoBehaviour
{
public AudioClip reload;
private AudioSource relses;
private Animation rel;
// Start is called before the first frame update
void Start()
{
relses = GetComponent<AudioSource>();
rel = GetComponent<Animation>();
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown("r"))
{
if(GlobalAmmo.CurrentAmmo > 0){
//in there ı want to stop (shotsound.cs)(handgundamage.cs)(crossanimate.cs)while animation play
rel.Play("reloadanim");
relses.clip = reload;
relses.Play();
if(GlobalAmmo.CurrentAmmo >= 10){
GlobalAmmo.CurrentAmmo -= 10 - GlobalAmmo.LoadedAmmo;
GlobalAmmo.LoadedAmmo = 10;
}
else{
if(GlobalAmmo.CurrentAmmo >= 10 - GlobalAmmo.LoadedAmmo){
GlobalAmmo.CurrentAmmo -= 10 - GlobalAmmo.LoadedAmmo;
GlobalAmmo.LoadedAmmo = 10;
}
else{
GlobalAmmo.LoadedAmmo += GlobalAmmo.CurrentAmmo;
GlobalAmmo.CurrentAmmo = 0;}
}
}
}
}
}
Comment