I am using the FPS template, and FMOD, and I want to trigger a different impact sound for the projectile when it hits the floor, the walls, and the crates. Can anyone help me with a blueprint that will achieve this? The part I am confused about is the check that needs to be sent out when the projectile collides with something. I am unsure how to hook something like that up.
When you are line tracing for the hit surface you can get the physics material of the Hit then easily use a Switch to call different things depending on what the phys mat was. Several materials can use the same physics material.
To set up a phys mat, you do so through the Project Settings>Physics, you may need to restart the editor.
Then from your HitResult Struct, get phys Mat and Surface Type, whatever you added will be visible there so if you added Rock, Sand etc. they will appear so you can spawn different vfx and play different sfx depending on what it was.
Next create a PhysMat by Right Clicking in the Content Browser>Physics>Physics Material. From there you can specify what physics material it is, for example rock. Then in the Material you can add that phys material on the left side.
However, if you are using a lot of Vertex Painting on your surfaces where one material could have several different painted “materials” like moss an cobble, then i think you need something more advanced where you can detect what is painted on that vertex.
I am actually making a plugin for it right now where you can get the value out of each vertex channel and use it with datables to easily return what value a surface has that you can hook up to FMOD or WWise. Should be done in about a week.
There is also a way to get the material from the ‘face index’ break result. But then you still have to setup a lit of different sounds for different materials. So it kinda amounts to the same thing.
Hey thanks a lot for the reply I really appreciate it! That’s great, that solves the more complicated part of my problem. So to setup the rest of the blueprint, I would need to have 3 different surface types (floor, wall, crate) and then have 3 different branches? Off these branches I would need 3 different ‘play FMOD event at location’ nodes each loaded with the relevant sound effects. I Imagine I need some kind of call out before the sound events so the engine can check what surface the projectile collided with? And is this Break hit result to be added onto the projectile actor?
Apologies for any extreme beginner language, this is my third day diving into unreal and I’m having a blast!
Yes then you would have to add Floor, Wall and Crate in the Project Settings>Physics from the first picture.
Then when you restart the editor, if you make a Line Trace for the Hits on the surface, drag the blue pin to the right of it and Break it, then you will get the one on the second picture. from there you can as you see get surface types, drag out from surface type and write Switch and you can break it up into a switch so you have different execution pins for each surface.
If you are detecting the surfaces with a projectile then yes, you will need a HitComponent event in the projectile, it will also return a Hit Struct. I thought it was just a regular gun at first, then you don’t have to bother with Line Tracing, just make a Hit for projectile. Make sure its collision settings is set to Generate Hits and that it blocks for example world static etc.