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

**URL:** <https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072>\
**Category:** Editor Scripting\
**Tags:** unreal-engine, question\
**Created:** [January 19, 2023, 6:49pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072 "2023-01-19T18:49:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![danbrownea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@danbrownea](https://forums.unrealengine.com/u/danbrownea)\
**Post date:** [January 19, 2023, 6:49pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/1 "2023-01-19T18:49:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 19, 2023, 6:52pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/2 "2023-01-19T18:52:54Z")

</div>

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

Run it from the construction script.

---

<div class="post-metadata">

**Author:** ![danbrownea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@danbrownea](https://forums.unrealengine.com/u/danbrownea)\
**Post date:** [January 19, 2023, 6:55pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/3 "2023-01-19T18:55:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 19, 2023, 6:57pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/4 "2023-01-19T18:57:09Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/b/0ebe782ee9bc3da685e13c9682365b2553316b23.png)

---

<div class="post-metadata">

**Author:** ![danbrownea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@danbrownea](https://forums.unrealengine.com/u/danbrownea)\
**Post date:** [January 19, 2023, 7:00pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/5 "2023-01-19T19:00:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 19, 2023, 7:01pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/6 "2023-01-19T19:01:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danbrownea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@danbrownea](https://forums.unrealengine.com/u/danbrownea)\
**Post date:** [January 19, 2023, 7:04pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/7 "2023-01-19T19:04:40Z")

</div>

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.

 ![Capture](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/9/4e98359b6d0be2c04e1ca99de50dd7797f27aa41.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 19, 2023, 8:41pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-show-a-dynamic-preview-mesh-in-the-level-viewport/753072/9 "2023-01-19T20:41:43Z")

</div>

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 ).

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/2/8c2408d7c7b7e0e546892bb0aa2c398d3a1efe35.png)

Then in the spawner, we have

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/7/ba760348710a6a84fb32855aac603fa1a69fba63.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/1/071c306067d7b519df4df9813c7fd79e61198dd5.gif)
