# How to create a persistent C++ object in blueprints?

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268>\
**Category:** Blueprint\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [October 5, 2015, 12:02am UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268 "2015-10-05T00:02:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_1d166e351](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1d166e351](https://forums.unrealengine.com/u/anonymous_user_1d166e351)\
**Post date:** [October 5, 2015, 12:02am UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268/1 "2015-10-05T00:02:43Z")

</div>

Hi,

I have a C++ class of type UObject and I want to know what I need to do so that it is persistent throughout the game. I want to be able to create the object in the blueprints and then call functions on it when needed. I can’t figure out how to do that in the blueprints.

Thanks

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [October 5, 2015, 2:04am UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268/2 "2015-10-05T02:04:49Z")

</div>

I think all UObjects are persistent, you spawn therem with this node:

> **[Construct Object from Class](https://docs.unrealengine.com/5.1/en-US/BlueprintAPI/Game/ConstructObjectfromClass/)**
>
> Construct Object from Class

Theres also class dedicated for persistent game data, so maybe extend from that or spawn from that:

> **[UGameInstance](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/Engine/UGameInstance/)**
>
> GameInstance: high-level manager object for an instance of the running game.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1d166e351](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1d166e351](https://forums.unrealengine.com/u/anonymous_user_1d166e351)\
**Post date:** [October 5, 2015, 1:46pm UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268/3 "2015-10-05T13:46:23Z")

</div>

Thank you for your answer. Is there anyway I can call functions on that object (construct object from class) through blueprints?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [October 5, 2015, 2:31pm UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268/4 "2015-10-05T14:31:28Z")

</div>

Yes, just cast return value to your class and from it you can call it’s function nodes same as you do with actors. I assume you know how to bind functions so they can be used in blueprint.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1d166e351](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1d166e351](https://forums.unrealengine.com/u/anonymous_user_1d166e351)\
**Post date:** [October 12, 2015, 1:08pm UTC](https://forums.unrealengine.com/t/how-to-create-a-persistent-c-object-in-blueprints/334268/5 "2015-10-12T13:08:50Z")

</div>

Got it to work. I had to construct the object from class, set it to a variable (to be reused later), and made the function blue-printable in the header also. Thanks.
