# Fast firing weapon problems

**URL:** <https://qa.fmod.com/t/fast-firing-weapon-problems/17287>\
**Category:** FMOD Studio\
**Created:** [June 3, 2021, 1:19pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287 "2021-06-03T13:19:23Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Skaven252](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/skaven252/32/63_2.png) [@Skaven252](https://qa.fmod.com/u/Skaven252)\
**Post date:** [June 9, 2021, 7:38am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/23 "2021-06-09T07:38:14Z")

</div>

Variable rate can also be achieved on the timeline. If you raise the event master pitch (from the event macros), the timeline runs faster. If you then pitch down the multi-sounds in the timeline by the same amount (ie, you have a linear pitch-up envelope in master pitch, and a linear pitch-down envelope of the same amount in the multi-sounds) you have variable trigger rate. This can be helpful sometimes if you want to sequence multiple layers of sounds (like gun shots, slaps and mechanics) on a timeline.

---

<div class="post-metadata">

**Author:** ![Skaven252](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/skaven252/32/63_2.png) [@Skaven252](https://qa.fmod.com/u/Skaven252)\
**Post date:** [June 9, 2021, 7:49am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/24 "2021-06-09T07:49:21Z")

</div>

Another thread on variable / dynamic fire rate:

> [@Dynamic firerate for weapon](https://qa.fmod.com/t/dynamic-firerate-for-weapon/15481):
>
> Hey Guys, i am trying to make a gunshot loop with a variable as firerate. So i want to jump to the start of the loop sooner, when the firerate ist higher. But i dont see how that would be possible, because as far as i understand transition markers only trigger at a certain condition, for example when my firerate variable would have a certain value. So i would have to create a marker for every firerate possible wich sounds like a nightmare, because that would result in roughly thousand hand plac…

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [August 16, 2021, 10:43am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/25 "2021-08-16T10:43:21Z")

</div>

Ok, still having problems. I updated FMOD and the scatterer instrument works now. If I create a sustain point and press “KeyOff”, everything stops as intended.

The problem is how to implement this in game. What code should you write to call the key off?  
Currently we are doing this:

EventInstance.triggerCue();

But this results in the weapon only playing the firing sound every 3rd time or so, when I actually press the fire button. The audio only plays now and then when pressing the fire button.

Thanks

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [August 16, 2021, 10:51am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/26 "2021-08-16T10:51:17Z")

</div>

I don’t know how to correctly implement the keyoff in Unity or with the API. However, there’s a nice workaround: condition the trigger point to “event stopped” (I will assume you have a recent enough FMOD version). That way, you’ll only need to stop the event to have the sustain point triggered.

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [August 16, 2021, 10:58am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/27 "2021-08-16T10:58:36Z")

</div>

Ah, like this?  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c5ef00c7d8e74f2bf03e2ebcde720b62b795c6d8.png)

If I make the event stat “Stopping”, then it doesn scatter correctly. It only plays the sound once and does not scatter.

But the above picture setting, seems to work, at least in fmod. Will have to ask programmer to revert to stopping the old way before i can test

Thanks man!🙂

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [August 16, 2021, 11:09am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/28 "2021-08-16T11:09:26Z")

</div>

Yes, “not stopping”, that’s what I meant 🙂

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [August 16, 2021, 11:25am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/29 "2021-08-16T11:25:10Z")

</div>

Cool. Will test:)

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [August 16, 2021, 12:45pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/30 "2021-08-16T12:45:35Z")

</div>

Ok, seems to work. I do get some delay sometimes though, when i press down the firing button for a long time, and release the button, the firing sound stays on for maybe 0.5 sec or so. But this might be a programming thing and not something with fmod.  
But thanks:)

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [August 18, 2021, 6:00am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/31 "2021-08-18T06:00:50Z")

</div>

I remember some delay issues have been reported when using the event stopping state. It was advised to change a setting in fmod initialization. It this persists, it may be preferable to implement the keyoff.

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [August 18, 2021, 6:48am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/32 "2021-08-18T06:48:55Z")

</div>

Ok, could anyone tell me how to do proper key off in code? Need to pass that info on to the programmer.  
thanks:)

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [August 18, 2021, 6:55am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/33 "2021-08-18T06:55:38Z")

</div>

Information on how to key off a sustain point from code can be found in our [documentation](https://fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventinstance.html#studio_eventinstance_keyoff).

---

<div class="post-metadata">

**Author:** ![BubbleBoi](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@BubbleBoi](https://qa.fmod.com/u/BubbleBoi)\
**Post date:** [May 10, 2022, 11:53am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/34 "2022-05-10T11:53:12Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/6d3000440cd4972fcc8339ceb313d6ebfef52328.png)

Usually I put a jump marker after every bullet and it works great

---

<div class="post-metadata">

**Author:** ![Skaven252](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/skaven252/32/63_2.png) [@Skaven252](https://qa.fmod.com/u/Skaven252)\
**Post date:** [May 10, 2022, 6:41pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/35 "2022-05-10T18:41:24Z")

</div>

If you can find and match the exact BPM of the firing loop, you can use a transition region with the “transition on beat” option. Though … if it’s a very fast firing gun, the BPM setting may not accommodate that. Anyway, that’s one way to avoid having to add a transition marker to every shot in the loop.

---

<div class="post-metadata">

**Author:** ![trjaudio](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@trjaudio](https://qa.fmod.com/u/trjaudio)\
**Post date:** [May 12, 2022, 8:37am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/36 "2022-05-12T08:37:59Z")

</div>

Great solutions Bubbleboi and Skaven. Thanks

---

<div class="post-metadata">

**Author:** ![TomassoAlbinoni](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@TomassoAlbinoni](https://qa.fmod.com/u/TomassoAlbinoni)\
**Post date:** [November 21, 2022, 5:48pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/37 "2022-11-21T17:48:56Z")

</div>

@Alcibiade @trjaudio

(edit: solved those issues, solution in post under this one)

Hello guys!  
I’m using this scatterer approach in the event.  
The weapon can receive a power up, and I’m having “boosted layer” with scatterer for that.  
I am using a Parameter and trigger conditions, so the boosted layer scatterer plays when the parameter is telling it “hey, the weapon is boosted, play that scatterer!”

**1. The problem is** , when the playhead is already on the sustain point, instrument Triggering Conditions don’t react to this (so when a person is shooting and during that shooting receives a boost, or the boost wears out while shooting).

So when the parameter goes up to 1(boosted) from 0(non-boosted), Scatterer doesn’t play.  
When the parameter goes to 0 (non-boosted) from 1(boosted), Scatterer keeps on playing.

Do you have any ideas on how to make the scatterer react?  
I thought it might be a Sustain point stuff. So I created a test event with a loop and it seems Scatterer won’t check the conditions again once it’s running.

[https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/5d7cbb7c46b9584655eb3785289ad86123401f01.mp4](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/5d7cbb7c46b9584655eb3785289ad86123401f01.mp4)

**2. If it’s impossible** to set it up correctly to have it working like described above (scatterer turns on/off on the run, based on parameter conditions), I can only think about running the Scatterer always and automating volume with the parameter, but that will probably be messy with either cutting the tails or tails popping up (when you fired the last shot but the event in those last moments got a parameter update to the boosted state).

**I just tried testing a workaround to this tail problem:**

- having transients as scatterer, volume based on parameter
- having tail as multi instrument, on the right of sustain point

**But… the tail multi instrument seems to ignore the changes in the parameter made during sustain!**  
When I start the event with parameter set to 0 (non boosted), tail doesnt play when releasing the sustain point. ✅  
When I start the event with parameter set to 1 (boosted), it plays when releasing the sustain point. ✅  
When I start with 0 and before releasing it changes to 1, tail wont play! ⁉  
When I start with 1 and before releasing it changes to 0, tail plays! ⁉

[https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/41da22bdaa34f8031ccb72fb9f909d13e353605e.mp4](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/41da22bdaa34f8031ccb72fb9f909d13e353605e.mp4)

@joseph If scatterer behavior described in **1.** isn’t actually a bug, I think the second thing is. Could you confirm it, or am I getting something wrong?

---

<div class="post-metadata">

**Author:** ![TomassoAlbinoni](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@TomassoAlbinoni](https://qa.fmod.com/u/TomassoAlbinoni)\
**Post date:** [November 21, 2022, 6:07pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/38 "2022-11-21T18:07:27Z")

</div>

Maybe I’ll leave the above so the people with similar problem might find the solution.

I just tested automating the volume of scatterer with Parameter. It didnt work and that was too weird.

All issues described by me above were caused by **Hold value during playback.** in the parameter.  
I’ve set it like this to prevent the parameter from stealing the tails in more one-shot weapons, but I think it still doesnt make much sense when the instances are separate. Now I understand it more 🙂

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [November 22, 2022, 2:51am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/39 "2022-11-22T02:51:43Z")

</div>

@TomassoAlbinoni, I’m glad to hear you were able to get the behavior you wanted.

> [@TomassoAlbinoni](#):
>
> All issues described by me above were caused by **Hold value during playback.** in the parameter.  
> I’ve set it like this to prevent the parameter from stealing the tails in more one-shot weapons, but I think it still doesnt make much sense when the instances are separate.

When you say “the instances are separate,” what do you mean?

“Hold value during playback” is designed for use with event instruments, as a way of allowing the parameter’s value to be set when a new instance of a referenced event is first spawned, without subsequent changes to the parameter’s value in the parent event instance propagating to the child event instance. It is rarely useful in event instances not spawned by event instruments.

I’m not sure what you mean by “preventing the parameter from stealing the tails in more one-shot weapons.”

---

<div class="post-metadata">

**Author:** ![TomassoAlbinoni](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@TomassoAlbinoni](https://qa.fmod.com/u/TomassoAlbinoni)\
**Post date:** [November 23, 2022, 3:22pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/40 "2022-11-23T15:22:53Z")

</div>

For some reason I thought if I play instance A with given parameter value, the next instance B that spawns with it’s own value, is going to override A’s value.

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [November 23, 2022, 11:10pm UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/41 "2022-11-23T23:10:08Z")

</div>

> [@TomassoAlbinoni](#):
>
> I thought if I play instance A with given parameter value, the next instance B that spawns with it’s own value, is going to override A’s value.

That only happens if it’s a global parameter, since each global preset parameter has one value that’s shared globally by all event instances. If it’s a local parameter, then each event instance can have its own parameter value.

---

<div class="post-metadata">

**Author:** ![TomassoAlbinoni](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@TomassoAlbinoni](https://qa.fmod.com/u/TomassoAlbinoni)\
**Post date:** [January 31, 2023, 10:28am UTC](https://qa.fmod.com/t/fast-firing-weapon-problems/17287/42 "2023-01-31T10:28:18Z")

</div>

I thought I’ll continue there, as this is highly related to what’s posted above - scatterer for fast weapons (and fire rate needs to be variable).

Problem is - Scatterer keeps stuttering at higher rates (@trjaudio wrote that it’s been fixed in some version but I’m at 2.01.16 and it’s still there).  
It seems though it’s only more audible at higher rates, and uneven time intervals are happening at slower rates too, have a listen (0:14-0:15 especially):

[https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/34b9942ead816c1d403b50ed47dade6d2a960685.mp4](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/34b9942ead816c1d403b50ed47dade6d2a960685.mp4)

Is there something I can do about this? Or is it just Scatterer that is not built for this purpose and it just won’t play samples in fixed time intervals (and will just put some ms here and there)?  
Any idea @joseph @Alcibiade ?

[Previous page](https://qa.fmod.com/t/fast-firing-weapon-problems/17287.md?page=1)

[Next page](https://qa.fmod.com/t/fast-firing-weapon-problems/17287.md?page=3)
