I’m trying to get all static meshes which have a tag ‘GLASS’, and add to an array so I can reference later on however this keeps making a ‘infinite loop’.
Getting all STATIC meshes with tag, is really bad idea. Your code needs to go trough all static meshes and check if they have tag. This would work in small levels with max 1000 or so meshes.
Explain what it is for, there may be more optimal solutions to what you want do.
For ex making actors out of those meshes, then using dispatcher in place like game mode where those meshes can hook.
OR making blueprintable actor component that can be dropped on any mesh and do its own stuff.
Also getting reference to all meshes with tag is bad idea, because all those meshes will be ALWAYS loaded to memory as long as anything in memory has those references stored.
Hi Nawrot, thankyou for replying so fast - the whole problem I have is because I have a group of houses and when i select a housetype model there is a feature that ‘isolates’ from the rest of the development, it does this by using a virtual texture map that masks the opacity of materials (excluding the plot that’s selected). This resualts in only the plot visible, however this caused visual artefacts in the glass reflection still showing other windows from other houses in the reflection of the isolated plot.
So I created a utility widget that applied a tag to only selected components with specefic names such as windows, doors, dormers, canopys etc.. this worked fine.
My next step was to hide these objects in scene, however when I had originally done this on the fly there was a noticeable half second or so between the plot isolating and the windows disappearing because of all the calculations that had to be done (what you said too expensive).
Long storey short… I figured if I could get most of that calculated on begin play, I can just reference the meshes with that tag, stored in a variable.