Shooting - fully automatic sound override

solex86

New member
Hi,

I'm getting the hang of configuring my assault rifle! Only thing I can't really figure out from the editor is how/if I can customize the firing sound for single shot AND automatic fire. I have a nice audio loop for fully automatic firing which is different from a single shot repeating. In my current mindset I see two options:

- Create a firing mode toggle for the AR: single shot OR full auto (and select a different audio file for each)
- Have it always be full auto fire, but change the sound based on mouse down/up duration.
 
Hi,

I'm getting the hang of configuring my assault rifle! Only thing I can't really figure out from the editor is how/if I can customize the firing sound for single shot AND automatic fire. I have a nice audio loop for fully automatic firing which is different from a single shot repeating. In my current mindset I see two options:

- Create a firing mode toggle for the AR: single shot OR full auto (and select a different audio file for each)
- Have it always be full auto fire, but change the sound based on mouse down/up duration.
Hi @solex did you come to a good solution for using an Audio loop and single shot?

Or even just a way to use audio loop at least
 
Hi, couldn't figure this out, could you explain a little more on how this is done? I've been reading the document you sent but it's still a little confusing how this is achieveable
Hi, I managed to get an ok fix, but it's not perfect especially the 'single shot sound's timing when releaseing, but it's certainly decent and allows me to use any looped machine gun sound.

- However it does not use the Animator Audio State

This is roughly how I've done it:

I have an audio source object child of the Rifle/Weapon, with my script and audiosource
THen a second audiosource object also child of the weapon for the 'single' shot audio. (can probably do it all on one object, this was just how I did it)

1. OnUpdate 'Fire1' input > ShootableWeapon.IsItemInuse = false > disable loop audio source

OnUpdate 'Fire1' input > ShootableWeapon.IsItemInuse = true
> if ShootableWeapon.GetConsumableItemIdentifierAmount = 0 > play dryFire Audio
> if ShootableWeapon.GetConsumableItemIdentifierAmount = 1 > play single/final audio
> if ShootableWeapon.GetConsumableItemIdentifierAmount = >1 > play Loop audio

Each of the three above run on a 'once' function (I use Bolt Visual scripting, and I don't know what C# method 'once' uses sorry, but it allows something to occur only once in a frequent/update loop and wait for reset - could just use a bool variable)

So each of these three can only run once while the 'Fire1' input is pressed.

When 'Fire1' is 'unpressed' my script/flowmachine 'resets' these once functions so they can work on the next input.

I think my way of checking 'IsItemInUse' and then 'GetConsumableItemIdentifierAmount' is a solid way to decide whether to play dryfire/loop/single+final shot.

As far as the 'timing' of the final shot it's probably not the nicest, as it can result in a quicker than reality final shot after the previous shot heard in the loop track, but it mostly goes unnoticed particularly when the loop rate of fire is rapid.

The other benefit is when the rate of fire is quite rapid, the overall effect of this is that it matters not at all whether the audio timing matches the firing animation because it's so fast.

Lastly, my use of the 'once' function and resetting with 'unpressed' and such could likely be a lot simpler and efficient, but haven't updated it because it just works fine!

I have had some issues to get back to where just equipping the weapon activates the single/final shot, but haven't done it yet and sure it will be simple.
 
Last edited:
Hi, I managed to get an ok fix, but it's not perfect especially the 'single shot sound's timing when releaseing, but it's certainly decent and allows me to use any looped machine gun sound.

- However it does not use the Animator Audio State

This is roughly how I've done it:

I have an audio source object child of the Rifle/Weapon, with my script and audiosource
THen a second audiosource object also child of the weapon for the 'single' shot audio. (can probably do it all on one object, this was just how I did it)

1. OnUpdate 'Fire1' input > ShootableWeapon.IsItemInuse = false > disable loop audio source

OnUpdate 'Fire1' input > ShootableWeapon.IsItemInuse = true
> if ShootableWeapon.GetConsumableItemIdentifierAmount = 0 > play dryFire Audio
> if ShootableWeapon.GetConsumableItemIdentifierAmount = 1 > play single/final audio
> if ShootableWeapon.GetConsumableItemIdentifierAmount = >1 > play Loop audio

Each of the three above run on a 'once' function (I use Bolt Visual scripting, and I don't know what C# method 'once' uses sorry, but it allows something to occur only once in a frequent/update loop and wait for reset - could just use a bool variable)

So each of these three can only run once while the 'Fire1' input is pressed.

When 'Fire1' is 'unpressed' my script/flowmachine 'resets' these once functions so they can work on the next input.

I think my way of checking 'IsItemInUse' and then 'GetConsumableItemIdentifierAmount' is a solid way to decide whether to play dryfire/loop/single+final shot.

As far as the 'timing' of the final shot it's probably not the nicest, as it can result in a quicker than reality final shot after the previous shot heard in the loop track, but it mostly goes unnoticed particularly when the loop rate of fire is rapid.

The other benefit is when the rate of fire is quite rapid, the overall effect of this is that it matters not at all whether the audio timing matches the firing animation because it's so fast.

Lastly, my use of the 'once' function and resetting with 'unpressed' and such could likely be a lot simpler and efficient, but haven't updated it because it just works fine!

I have had some issues to get back to where just equipping the weapon activates the single/final shot, but haven't done it yet and sure it will be simple.
Thank you for this, i will give this a shot!
 
Top