# Reference Static Mesh Outside of Constructor

**URL:** <https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 30, 2015, 7:53pm UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903 "2015-09-30T19:53:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CosmicDreamStudios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CosmicDreamStudios](https://forums.unrealengine.com/u/CosmicDreamStudios)\
**Post date:** [September 30, 2015, 7:53pm UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903/1 "2015-09-30T19:53:26Z")

</div>

Trying to reference a Static Mesh but not through ConstructorHelpers::FObjectFinder. Is this possible? I’m referencing Kamrann’s post here:

> **[Adding component OnConstruction](https://forums.unrealengine.com/questions/258151/adding-component-onconstruction.html)**
>
> Hello, I am trying to add a static mesh component in OnConstruction inside an extended actor class as shown in screenshots below. However if I create a blueprint with base class as “ATestActor” C++ class and place it in the scene, the mesh can be...

The reason for this is that before I add components, I was asking the GameMode for certain variables. But referencing GameMode in the constructor returns NULL which I read here its a bad idea to reference objects in the constructor:  
[https://forums.unrealengine.com/archive/index.php/t-37892.html](https://forums.unrealengine.com/archive/index.php/t-37892.html)

Anyone have an idea how to do this then? Just need to grab the object with this reference:  
“StaticMesh’/Game/Objects/BuildingFloor.BuildingFloor’”

I’d appreciate any help!

---

<div class="post-metadata">

**Author:** ![CosmicDreamStudios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CosmicDreamStudios](https://forums.unrealengine.com/u/CosmicDreamStudios)\
**Post date:** [September 30, 2015, 8:40pm UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903/2 "2015-09-30T20:40:33Z")

</div>

Ok, upon further research i found a link here which i think details the process. I’ll post again if this works.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![CosmicDreamStudios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CosmicDreamStudios](https://forums.unrealengine.com/u/CosmicDreamStudios)\
**Post date:** [October 1, 2015, 1:40am UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903/3 "2015-10-01T01:40:30Z")

</div>

I haven’t been able to get the code to work. It appears to load the object from the path but then the NewObject Command says the static mesh is null? Does anyone have an idea?

 ![60949-nullstaticmeshnewobject.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/7/227d986a04cbd3d3721d7a91c8a41bdb813900a3.jpeg)

---

<div class="post-metadata">

**Author:** ![CosmicDreamStudios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CosmicDreamStudios](https://forums.unrealengine.com/u/CosmicDreamStudios)\
**Post date:** [October 1, 2015, 3:52am UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903/4 "2015-10-01T03:52:15Z")

</div>

Got it to work after finding that RegisterComponent must not be what is needed in this instance. Apparently RegisterComponentWithWorld(GetWorld()) is the way to go. Hopefully this will help someone later who has the same issue.

---

<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:22pm UTC](https://forums.unrealengine.com/t/reference-static-mesh-outside-of-constructor/333903/5 "2020-08-28T17:22:36Z")

</div>

this link is sadly no available anymore, this is the second time i find this, and it is really saddening because this is blocking my whole project ☹
