Add instance of instanced static mesh in blueprint construction script?

I’m trying to wrap my head around how to properly use instanced static mesh objects for dynamic creation of object layouts. From [this post][1] I’m experiencing intermittent crashes (typically on editor reload after saving and sometimes when building the lighting though not always) when I have a blueprint with instanced static meshes having instances added within the blueprint’s constructor.

Is there a proper way to add a fixed number of instanced static meshes within a blueprint’s constructor?

Below are images detailing the contents of the blueprint for reference - the perplexing thing is it seems to compile fine and works in maps fine, but when the engine is restarted it will crash unless I remove the blueprint until it loads then add it back in.

Edit: Based on [this link][6] it seems I’m taking the wrong approach here - so how would I create a bunch of static meshes as part of an object in a programmatic way if not in the construction script?

Hello ,

I was able to get your project to work by opening your level called HZ_Floor1 and then I deleted the current CageB from the level to clean up any information that may have been lingering from before I altered the blueprint’s construction script. I then moved the logic that was originally in the construction script of CageB and placed it into a blank actor. All that was left was to cast to CageB for the information needed for the objects that needed to be spawned and then I placed the new blank actor into the level with a fresh CageB. I hope this helps.

Blueprint of the blank actor that I used.

Make it a great day

I followed your instructions in moving the code to a separate actor named CageWallSpawner (I changed the blueprint from the one you presented slightly in removing the sequence to put the for loop after the cast such that it would execute for each instance of a CageB in a level) then placed a new CageB and CageWallSpawner in each map - I was able to build the lighting and switch between the maps but after saving and closing/reopening the editor it is still crashing - I’ve tried opening it 3 times thus far and it isn’t giving any useful error messages, just “Unreal Engine has stopped working” via the windows error reporting system.

Hello ,

I have closed and reopened the project and I have no longer receiving any crashes. Just to make sure that we have the same setup. I have changed my nodes so that it will apply to all instances of CageB. Note: you will need to click compile in your “CageWallSpawner” to see the changes added to the viewport after adding a new CageB.

Current blueprint setup that works for all instances of CageB with no crashes.

OK, I’ve possibly found the issue - though sadly it raises another.

The good news: I had the Mobility setting for the two Instanced Static Mesh Components set to Static - after setting them to Movable the project can be reopened after being closed without causing the editor to crash (there are also some shadows out of place even after building the lighting before closing the editor and experiencing the crashes).

The bad news: With the Mobility setting not Static I get the warning when building lighting saying “Large actor receives a pre-shadow and will cause an extreme performance hit unless bCastDynamicShadow is set to false.” and the subsequent large drop in FPS.

Is there a workaround for this?

Thank you for your assistance, it definitely isn’t crashing anymore as I’ve opened and closed the editor several times, switched levels, built lighting, etc.

I’ve created a new post based on the lighting issue I’m experiencing after this fix here and felt I should link it from this thread incase someone with the issue finds it in search results.

Hello ,

I am happy to hear that the fix provided has worked for you. I hope that your lighting issue is resolved soon.

Make it a great day