Need help getting reload animation in fps game that I'm making.
I keep getting "animation state HandGunReloading could not be played because it couldn't be found please attach an animation clip with the name HandGunReloading or call this function only for existing animations. UnityEngine.Animation:Play(String) HandGunReloading:ActionReload() (at Assets/HandGunReloading.js:48) HandGunReloading:Update() (at Assets/HandGundReloading.js:24) Here is the script that I'm using: var Reloading : AudioSource; var CrossObject : GameObject; var MechanicsObject : GameObject; var ClipCount : int; var ReserveCount : int; var ReloadAvailable : int;
function Update () { ClipCount = GlobalAmmo.LoadedAmmo; ReserveCount = GlobalAmmo.CurrentAmmo;
if (ReserveCount == 0) {
ReloadAvailable = 0;
}
else {
ReloadAvailable = 15 - ClipCount;
}
if (Input.GetButtonDown("Reload")) {
if (ReloadAvailable >= 0) {
if (ReserveCount <= ReloadAvailable) {
GlobalAmmo.LoadedAmmo += ReserveCount;
GlobalAmmo.CurrentAmmo -= ReserveCount;
ActionReload();
}
else {
GlobalAmmo.LoadedAmmo += ReloadAvailable;
GlobalAmmo.CurrentAmmo -= ReloadAvailable;
}
}
EnableScripts();
}
}
function EnableScripts () { yield WaitForSeconds(1.1); this.GetComponent("Gunfire").enabled=true; CrossObject.SetActive(true); MechanicsObject.SetActive(true); }
function ActionReload () { this.GetComponent("Gunfire").enabled=false; CrossObject.SetActive(false); MechanicsObject.SetActive(false); ReloadSound.Play(); GetComponent.().Play("HandGunReloading"); } Please I need help.
-Superbhaley-
Your answer
![](https://koobas.hobune.stream/wayback/20220612163222im_/https://answers.unity.com/themes/thub/images/avi.jpg)