Hello guys, Is is possible to play an animation consecutively without waiting the currently animation end so another can start? Example, fire automatic weapon then play the shooting animation over and over without waiting its length. public void Fire(){ if (bulletsInMagazine > 0 && Time.time > nextFire) { nextFire = Time.time + fireRate; gunAnimations.Play ("Fire"); gunAnimations ["Fire"].speed = animationSpeed; Object bulletClone = Instantiate (bulletGO, bulletPlace.transform.position, bulletPlace.transform.rotation); Object bulletSoundClone = Instantiate (bulletSoundGO, bulletPlace.transform.position, bulletPlace.transform.rotation); Destroy (bulletClone, 0.6f); Destroy (bulletSoundClone, bulletSoundGO.GetComponent<AudioSource>().clip.length); subtractBullets (bulletsToShoot); } }
Consecutively - means one after the other without interruption so your question is an enigma. Look into the 'has exit time' option in the documentation. Since you are using code instead of mecanim I don't know the "code" equivalent to check/uncheck has exit time.
I believe he is looking for crossFade https://docs.unity3d.com/462/Documentation/ScriptReference/Animation.CrossFade.html
As has been mentioned, you can interrupt animations. Your script appears to be using the legacy animation system rather than Mecanim. You can change this line: Code (csharp): if (bulletsInMagazine > 0 && Time.time > nextFire) to this: Code (csharp): if (bulletsInMagazine > 0) and remove this line: Code (csharp): nextFire = Time.time + fireRate; Those changes should remove all delay and the animation would start over every frame. However having a fire rate less than the length of the animation should interrupt it, if my memory of the legacy system serves me well. [EDIT] I seem to remeber now that the legacy system required you to explicitly call Animation.Stop () before Animation.Play() if you are trying to interrupt. It has been years though so I could be wrong. Cheers, TrickyHandz