Please Help :) Different Gun Sounds

Yo dev crew

i need some help im following a tutorial but i want to have my guns have different fire sounds?

i have rifle, sniper, shotgun…

ive added attached for you to see

ive added the gun sounds in the weapon bp but i dont know how to say when i have this gun play this sound etc

hope this makes sense

as you can see from the blueprint all im playing right now is the rifle sound for each gun as its simple

thanks alot

try creating an Interface. Lets give it a name and call it ‘makeanoise’
With an interface you can have the same named event (makeanoise) in many different blueprints. Each blueprint can then do a different action depending on what you want. You could then call the event makeanoise for each weapon and play a different sound. You could add a makeanoise event to any blueprint you like and they could all do different things.

I’m still new to UE4 so not sure how I’d implement this

I can create interface but not sure how I’d get it to work when actually pressing the fire action

Thanks for your help thou man

You add the interface to the gun/rifle/whatever blueprint - I think it is under class defaults (top of screen) and then details on the right of screen. Once the interface exists then you use its event to play your weapon specific sound.
To call it you just have reference to your weapon (the weapon your character is using) in your character blueprint and drag out from that reference and type the name of the event - it should appear.
You hit your fire Key which triggers an event in your character blueprint. You get the weapon that the character is using and call the event in the weapon blueprint.

If you need any further guidance i have made a little guide for you, i have no clue on your experience or your current blueprint setup therefore i will cover it all.

Firstly i would setup my weapons using inheritance with a base class. Create a Blueprint Class → Actor. Name this "WeaponBase"
Inside of this blueprint is where you would add all of the things that every weapon would require, for example. Animations, Sounds, Mesh, Sights, damage, bullet range, fire rate, etc…
Set all of these variables “Instance Editable”

Add your mesh component, either Static mesh or Skeletal Mesh depending on your model. Then add a variable called “Fire Sound” type "Sound Base"

Then i would go into my “Event Graph” and create a Custom Event called “WeaponFire” i would then get a “Play Sound 2D” and attach my “Fire Sound” variable into the “Play Sound 2D”. Do not set the sound in the “WeaponBase” variable leave it empty.

Compile, save and close the blueprint class. Right-click on the “WeaponBase” and create a child actor name this to your weapon name, for example “Weapon_Name” Inside of the Child actor add all of your assets such as animation, sounds, Mesh, etc… and attach them to the variables that show up on the side, remember you are not creating new variables inside of the child actor your are settings them from the variables you made in “Weapon Base”

Go into your Character class and create a variable called “CurrentWeaponClass” type “WeaponBase” and set it as a Class Reference the purple ball, then create another variable called “CurrentWeapon” type “WeaponBase” set this one as an Object Reference, the light blue ball. Set the weapon you would like to fire as the variable for “CurrentWeaponClass” only classes that are linked to “WeaponBase” should appear including the child classes.

Finally add an input called “Fire” under action Mappings and bind it to any key the key set will be used to fire. Then get that input in your Character Class. I have added a picture of how to setup your character class for the fire.

This is the best way to setup a weapon it makes it very easy to create new weapons in a second plus it reduces the amount of code you will need.
If you have any questions feel free to ask i will try to answer them as best as i can.

I have included 4 pictures for extra guidance

I have noticed you are replicating this does not include networking but you can easily set that up yourself like you have done on your own pictures.

Cheers bro for your help again

Mr rapid thanks so much mate awesome reply can’t thank you enough… Let’s team up and make a game haha
Really thanks for great reply

For your first game I allways advise to follow the twin stick shooter tutorial since it covers a lot of basic things and the endresult is a ‘ful’ game loop

It is a good start to build upon

thanks dude