- Home /
Question by
originalhappiness1 · Mar 08 at 03:12 AM ·
animations
Trouble looping an animation a certain number of times
I am trying to make a shotgun reloading animation that plays however many times it takes to fully reload. I tried using a for loop but this only plays the animation one time.
if (Input.GetKeyDown(KeyCode.R) && ammoInMag != clipSize && totalAmmo >= 0) { for (int i = 0; i < clipSize - ammoInMag; i++) { reload.SetTrigger("isReloading"); StartCoroutine(Reload()); } return; }
Comment
Answer by sacredgeometry · Mar 08 at 08:42 AM
for(int i = 0; i < bulletCount; i++)
{
// Where animation is your Animation component i.e. GetComponent<Animation>();
animation.PlayQueued("isReloading");
}
https://docs.unity3d.com/ScriptReference/Animation.PlayQueued.html
Your answer