Hey guys, I am creating a first person shooter and I was wondering if there would be a way to spawn different emitters depending on the objects that I shoot? I am using a simple line trace for my bullets and I have emitters set up correctly to spawn on location of hit, but as of now I can only assign 1 emitter to spawn. Any help would be appreciated! Thanks a lot!
This is something that exists pretty much exactly how you want it.
I’m assuming you have a medium amount of particle systems for different types of objects (aka wood, metal, stone).
In that case you can use a Physical Material!
A physical material contains a bit of information regarding some physics properties (friction, destruction threshold (if you use it on a destructible), etc.). You can add a physics material onto any material to give it those properties. If you give them a name for each type of surface you want (again wood, metal, stone, etc) you can then on hit check which physics material is applied to the material you shot and based on that spawn an emitter of the appropriate type.
It still needs a function like “GetEmitter” where you enter a physics material, then check which one it is and return an Emitter Class but at least it removes the effort it’d take to distinguish between all materials and reduces it to only make it necessary to distinguish between each type of surface you want.
Could you possibly post a screenshot showing the setup you would do after the line trace? I can’t figure out how to get the physics material of the actor that I shoot.
The result of your trace will be a hit result. Break that and the physics material will be one of the variables contained by the struct “Hit Result”.
Alright I see that. So I need to create a function? I’m not entirely sure how to set that up, as I have never used functions before. What do I add inside the function and how do I call the function into my event graph?
…maybe you want to start with something simpler, closer to a tutorial if you are completely new?
I don’t mind helping but I’m not here to develop features for others or spoon-feed exact setups.
Depending on how you shoot either you trace already in which case you hook it up to your shoot button → trace → use hit result.
Or you have a projectile in which case you want to have the setup shoot button → spawn projectile → when it hits (“Event Hit”) → Use the hit result.