# Load Static Mesh With Path in c++

**URL:** <https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234>\
**Category:** Asset Creation\
**Tags:** unreal-engine, CPP, question\
**Created:** [August 28, 2014, 6:42am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234 "2014-08-28T06:42:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammadali1375\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammadali1375\_1](https://forums.unrealengine.com/u/mohammadali1375_1)\
**Post date:** [August 28, 2014, 6:42am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/1 "2014-08-28T06:42:02Z")

</div>

hi.  
how can I load static mesh in a TSubobjectPtr with a path.  
for example I have a mesh in my content in folder Mesh/Cube;  
Now I want load it with c++ code in a TSubobjectPtr like

```
TSubobject<UStaticMeshComponent> mesh = /* the mesh in Mesh/Cube */

```

---

<div class="post-metadata">

**Author:** ![staticvoidlol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@staticvoidlol](https://forums.unrealengine.com/u/staticvoidlol)\
**Post date:** [August 28, 2014, 7:15am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/2 "2014-08-28T07:15:32Z")

</div>

First you will need to create a default subobject in your constructor:

```
mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("mesh"));

```

Then, to set the actual mesh to use (can be done from anywhere):

```
UStaticMesh* meshToUse = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("pathToYourAssetHere")));

if(meshToUse && mesh)
{
    mesh->SetStaticMesh(meshToUse);
}

```

Please note that you will have to declare “mesh” as a class variable.

---

<div class="post-metadata">

**Author:** ![Duncan\_Dam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Duncan\_Dam](https://forums.unrealengine.com/u/Duncan_Dam)\
**Post date:** [August 28, 2014, 7:27am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/3 "2014-08-28T07:27:31Z")

</div>

You can use this

```
TSubobject<UStaticMeshComponent> mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
const ConstructorHelpers::FObjectFinder<UStaticMesh> MeshObj(TEXT("/Game/Mesh/Cube/YourMesh"));
mesh->SetStaticMesh(MeshObj.Object);
```

---

<div class="post-metadata">

**Author:** ![mohammadali1375\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammadali1375\_1](https://forums.unrealengine.com/u/mohammadali1375_1)\
**Post date:** [August 28, 2014, 7:42am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/4 "2014-08-28T07:42:13Z")

</div>

thanks very much.

---

<div class="post-metadata">

**Author:** ![mohammadali1375\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammadali1375\_1](https://forums.unrealengine.com/u/mohammadali1375_1)\
**Post date:** [August 28, 2014, 7:42am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/5 "2014-08-28T07:42:29Z")

</div>

thanks. i find what i need

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7a98883a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7a98883a](https://forums.unrealengine.com/u/anonymous_user_7a98883a)\
**Post date:** [February 10, 2017, 2:02pm UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/6 "2017-02-10T14:02:59Z")

</div>

is there a way to do this without PCIP in the current version 4.14?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cbf8aac6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cbf8aac6](https://forums.unrealengine.com/u/anonymous_user_cbf8aac6)\
**Post date:** [March 4, 2017, 12:16am UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/7 "2017-03-04T00:16:41Z")

</div>

Hi guys!! Do you have a tutorial for doing this? I want to load a mesh from path working in BP mode, but I can’t figure out how to do it ☹

I’m not a developer but I understand very well bluprints 😃

---

<div class="post-metadata">

**Author:** ![ANLevant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ANLevant](https://forums.unrealengine.com/u/ANLevant)\
**Post date:** [August 28, 2020, 5:38pm UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/8 "2020-08-28T17:38:05Z")

</div>

Doesn’t work outside constructors, beware

---

<div class="post-metadata">

**Author:** ![staticvoidlol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@staticvoidlol](https://forums.unrealengine.com/u/staticvoidlol)\
**Post date:** [August 28, 2020, 8:26pm UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/9 "2020-08-28T20:26:24Z")

</div>

See the other answer. StaticLoadObject() works anywhere.

---

<div class="post-metadata">

**Author:** ![Drew\_W](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/drew_w/32/760268_2.png) [@Drew\_W](https://forums.unrealengine.com/u/Drew_W)\
**Post date:** [May 24, 2024, 9:34pm UTC](https://forums.unrealengine.com/t/load-static-mesh-with-path-in-c/292234/10 "2024-05-24T21:34:15Z")

</div>

If you run into issues with FObjectLoader never being able to find any asset, it could be an issue with Live Coding that can be fixed by closing the editor, building in VS, and relaunching.
