Detect when any destructible mesh destructs in level blueprint
I'm putting a large amount of destructible meshes in my level, and want to detect when they are broken and then playing a sound at that location.
One way I could do this is through blueprints, by making every destructible mesh a blueprint and using the OnDestructed function.
However, since there is so many DMs in my level, changing them all into blueprints would be quite laggy. I know I can do this through the Level Blueprint as well, (by having it selected in the map, right clicking in the level blueprint and then creating a reference with an OnDestroyed node) but again, since I have so many that is a waste.
What I want to do is detect if any of them break and it to give me the location/ reference of the destroyed mesh. For example, if I created a DM of a tree, and I put three copies, I want an event to fire every time any of the tree breaks and then to give me a reference of that destroyed DM.
How is this done?
The simplest way would be to do a getAllActorsOfClass or GetallActorsWithInterface or getAllActorsWithTag that all have destructable, I would have all destructable actors inherit from a single base BP_destructableMesh class so that you can do a getallActorsOfClass(BP_DestructableMesh) and it will create an array.
Then theres a few ways you could go, such as creating a SetTimer function that calls a function say every 2s (although with 4.9's new tick rate setup you might be able to do something funky and unique) that checks if the length of the array has down down (aka actors got destroyed, aka DestroyActor)
A combination of that, maybe some blueprint interfaces, merging meshes/actors, would be your best bet without having to get into c++ since working with LOTS of actors can be so heavy with BP only as I'm sure you know.... you can get about 10-20x more destructable meshes when using C++ for their logic rather htan blueprints for the same framerate,
Let me know if this helps at all.
Don't forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going as well as keeping answerhub clean so that it gets removed from the "unanswered questions" catagory.
answered Sep 04 '15 at 11:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here