How to add UInstancedStaticMeshComponent at runtime?

Hi,

I’d like to add UInstancedStaticMeshComponents at runtime to my actor, but outside of the constructor. The reason for that is, that I have a TArray with static Meshes, that the user can fill with statis meshes. At runtime, for each of those added static meshes, a Instanced Static Mesh component should be added for each mesh, which then gets instances added to it as needed. I have a blueprintcallable method in my actor, that needs to add those components.

I tried storing components in an own TArray, where wheach component is created with the NewObject function. I also attach the component to the RootComponent and add instances. But nothing is rendered in the scene.

Can somebody tell me, what I am doing wrong here?

Cheers,

Christian

I forgot to call the RegisterComponent method on the new components. Now it is working as intended.

Hi, I too have a same problem. Could you please share your code. It’d be very helpful to refer as example !!!