How to add UInstancedStaticMeshComponent at runtime?

Crosspost from Answerhub: How to add UInstancedStaticMeshComponent at runtime? - UE4 AnswerHub


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?



You’re on the right track, you most likely simply need to register the component afterwards. Refer to this post for more details.


That was it, thank you very much mate <3