Is there a way to show a dynamic preview mesh in the level viewport?

I have an asset that is an AI actor spawner. It’s essentially just a bunch of logic for determining when to spawn that will eventually call SpawnAIFromClass. Is there any way to have the appearance of the spawner in the level viewport be a preview of the mesh of the AI that it would spawn?

In other words, if I place the spawner in the level and set it to spawn EnemyTypeA, I want to see EnemyTypeA appear at that position in the level viewport. Is this possible?

Yes, you can use ‘add skeletal mesh component’, to put the mesh there.

Run it from the construction script.

That’s going to require manual setting of that value every time, though, no? In other words, every time you change the spawn type, you would also need to go set the corresponding mesh in the mesh component.

No you make it so when the change the spawn type, the skel mesh component changes.

How am I supposed to get the mesh asset, though? All I have is a Pawn Class type as a variable.

The ‘eye’ thing on the variable means it can be set from the details panel when you put the BP in the level.

When you look there, it will be a list of all your skeletal assets.

I think we might be misunderstanding each other. This is the entirety of my class. EnemyToSpawn is a public variable. There is no mesh anywhere in the spawner. I want to be able to preview the mesh of the thing that will be spawned by SpawnAIFromClass.

Ok.

You need an inheritance hierarchy, so your parent pawn class, and children. Each sets it’s mesh in construction with an instance editable variable ( because that’s what happens in the parent ).

Then in the spawner, we have

where ‘pawn class’ in a variable of the parent class type.

Then you can set the class in the level, and see the mesh

pawn2