# Preview Meshes for C++ Actors

**URL:** <https://forums.unrealengine.com/t/preview-meshes-for-c-actors/428032>\
**Category:** Blueprint\
**Tags:** staticmeshcomponent, unreal-engine, Blueprint, CPP, question\
**Created:** [June 24, 2018, 6:20pm UTC](https://forums.unrealengine.com/t/preview-meshes-for-c-actors/428032 "2018-06-24T18:20:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steferich](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steferich](https://forums.unrealengine.com/u/Steferich)\
**Post date:** [June 24, 2018, 6:20pm UTC](https://forums.unrealengine.com/t/preview-meshes-for-c-actors/428032/1 "2018-06-24T18:20:33Z")

</div>

Hello!

I’m struggling abit with setting a preview-mesh using C++. I’ve created an actor class and a **UStaticMeshComponent** called “CurrentMesh” within it which I want to **assign** a **static mesh** to. I have also made a **TArray** of **static meshes** (which is blank until it’s edited in blueprints) which the UStaticMeshComponent can choose meshes from. If the index 0 of this array has been assigned I want to **apply** the mesh of it to my UStaticMeshComponent, although I don’t know how to accomplish this.

My main idea was to assign it in **PostInitProperties** , but whenever I compiled it would just return a breakpoint in **Array.h**. Here’s the breakpoint:

 ![245288-skjermbilde-2018-06-24-200342.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/a/ffa5a9646b256f4c35293cc0ae08618e8413363e.png)

Now, I see that checkf checks if the index is greater than the array length, so I put it into an if-statement which checks if the array-index is valid:

```
void ADefaultPlantActor::PostInitProperties()
{
	Super::PostInitProperties();

	if (MeshStages[0])
	{
		CurrentMesh->SetStaticMesh(MeshStages[0]);
	}
}

```

Although this didn’t fix anything, and just returned to the same breakpoint. And if this helps: I’m using **uint8** for my array.

Does anyone know how I would accomplish this? I simply want to **display a mesh/preview mesh** for the actor whenever I’m in the **editor**. Think of it as the blueprint-construct; you drag out from the construct node and set a static mesh like this:

 ![245289-skjermbilde-2018-06-24-201310.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/6/bf6b1023ef010ba0b264528912846c678544c41d.png)

Thanks in advance! 🙂

~Stefan
