Hi guys, I made a blueprint which I found useful to execute some automatic procedures with objects that are placed under a roof.
This can be useful during an open world production where you have tons of objects and you don’t want to rely on manual control on each of them.
In a production situation, you want your walls and roofs to be custom type blueprints to recognize them without the use of component tags, that we are using in this tutorial.
This is the setup of my example scene, some walls and roofs with component tags “Roof” and “Walls” assigned in the detail panel, and some basic shapes with None component tag.
Follows the setup of the blueprint and the explanation:
The blueprint gets all the actors of type “static mesh actor” from the scene, loop them checking the component tag of each and raycast from the right ones to check the collisions.
Let’s analyze it deeper.
It starts clearing the two temp arrays we use during the process, so every time we hit the custom event from the editor it will start from scratch. Then it gets the static mesh actors from the scene and copies them in a temp array.
Iterating the temp array we check each item component tag, and we create another temp array to get only the meshes with tags different from “Roof” and “Walls”.
Once the first loop is finished and we have a temp array (“None tagged meshes”) which contains just the meshes we want to use for the raytracing, we can go ahead and start doing that. The Z-Search value float is used to control the length of the ray, once the raytracing is over we check the hit component tag and, in this case, assign the right material to the object.
The next image shows the different materials applied to different objects based on what their raycast hit.
This process can be easily extended to other features, like checking also walls with multiple raycast.
Another solution can be a sphere collision which detect custom collisions defined for roofs and walls.
This was a basic tool but I hope it can be useful to someone.