# Continuous Fire Animations

### Difficulty: 1/10 <img src="/files/-MfzUfw94jUTyreywn9u" alt="" data-size="original">&#x20;

By default, the shoot animation of a gun will return to its idle frame when it is finished, even if the fire button is held down. However, this isn't always what is desired, particularly with certain automatic weapons where returning to the idle frame looks awkward.

This is where Continuous Firing Animations come in. Guns with continuous firing animations will loop the specified section of their animation while firing, and return to the first frame of their fire animation upon the fire button being released. (this is also useful for guns that may have some sort of warmup animation when they start to fire, such as a gatling gun whose barrel spins slow at first but gets faster).

## How to make a gun use a Continuous Fire Animation

1. Set up the gun's sprites and animation the way you would normally do it to begin with.&#x20;
2. Make sure the bool 'usesContinuousFireAnimation' is set to true, like this;

```csharp
gun.usesContinuousFireAnimation = true;
```

3\. Now you need to set up a looped section in the gun's firing animation, which you can do by using the code below.

```csharp
gun.GetComponent<tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).wrapMode = tk2dSpriteAnimationClip.WrapMode.LoopSection;
gun.GetComponent<tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).loopStart = 1;
```

Please note that the 'loopStart' variable is the frame on which the gun's animation will begin to loop. In this example, it is set to 1, but since computers count starting at 0, '1' actually refers to the *second* frame of the animation. For a loop to start on the first frame, 'loopStart' would have to be set to 0.

## Other Notes

It is worth mentioning that upon the fire button being released, the gun will return to the first frame of its *fire* animation, **not** its idle one. To get around this, it may be advisable to set the first frame of the fire animation to the idle frame and start the loop on the second frame.

This way, the gun will still have a continuous looping firing animation, but will not persist on it's firing animation once firing has ended (or so it will appear to any end-user).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mtgmodders.gitbook.io/etg-modding-guide/making-a-gun/continuous-fire-animations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
