Static mesh component not showing up on spawned actor

I have a custom actor class called “BlackHole”, which is supposed to spawn a new actor of class “DarkMatter” after being in existence for 5 seconds. For some reason, when my black hole actor spawns my dark matter actor, the dark matter static mesh I have selected does not show up in-editor. However, I can see that the dark matter has indeed spawned (according to the world outliner). I’ve been trying to figure this out for days with no success, why is the static mesh component not showing up? Any help is appreciated, thank you.

BlackHole.h:

BlackHole.cpp:

DarkMatter.h:

341728-unrealhelp-darkmatter-h.png

DarkMatter.cpp:

This is the relevant code for the spawning implementation, mostly just the CreateDarkMatter function in BlackHole.cpp.

1 Like

Yes, you set up your component with defaults but whats the mesh of this component ?

I can see that the dark matter has
indeed spawned (according to the world
outliner)

Also if you press F3 you may see its collision component too.
The thing is
you did not setup visual mesh.


2 approach here :

I pretty sure you have BP version of BlackHole.

Create BP subclass of DarkMatter, assign a visual mesh to StaticMeshComponent.

Then select ActorToSpawn in BlackHole BP as Dark Matter BP.

Second approach is fetch static mesh item to cpp via FObjectFinder

then setup your static mesh with :

Mesh->SetStaticMesh(ref.object);

Thanks a bunch! I had already tried the first method before posting, with no success, but using the second approach fixed my issue.