Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Unity does not recognize reload animation for gun

$
0
0
I am trying to make a reload script for my gun, so that when I hit 'R' my gun reloads, but the thing is that the animation and the reseting of current ammo doesn't work. What's the problem here? var SMG : GameObject; var smg_script : MonoScript; var Ammo = 54; var CurrentAmmo = 54; var Wait : float; function Update () { if(Input.GetButtonDown("Fire1")){ CurrentAmmo -= 1; if(CurrentAmmo == 0){ Reload(); } else if(Input.GetButtonDown("R")){ if(CurrentAmmo < 54){ Reload(); } } } } function Reload () { SMG.animation.Play(); yield WaitForSeconds(Wait); CurrentAmmo = 54; }

Viewing all articles
Browse latest Browse all 592

Trending Articles