# Initialize object of custom class from blueprint

**URL:** <https://forums.unrealengine.com/t/initialize-object-of-custom-class-from-blueprint/373765>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 19, 2016, 8:30am UTC](https://forums.unrealengine.com/t/initialize-object-of-custom-class-from-blueprint/373765 "2016-10-19T08:30:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mesothere](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mesothere](https://forums.unrealengine.com/u/Mesothere)\
**Post date:** [October 19, 2016, 8:30am UTC](https://forums.unrealengine.com/t/initialize-object-of-custom-class-from-blueprint/373765/1 "2016-10-19T08:30:43Z")

</div>

Hi guys,

I’ve created a C++ class called “Item” that holds an array of another class of mine, named “ItemEvent”. This works fine if I add events via C++, but for ease of use I’m trying to enable the addition of events via blueprint also.

I have several blueprints that derive from “item”. Item has a function named “AddEvent” which accepts a pointer to an ItemEvent and simply adds it to the existing TArray. My issue is that, when I create new variables in my blueprint of my various ItemEvent types, they are never initialized by default.

I have begun trying to call the following node on the BeginPlay event to initialize these objects:

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

My issue is that this does not work, and provides the following error:

[https://forums.unrealengine.com/attachment.php?attachmentid=114349&d=1476830567](https://forums.unrealengine.com/attachment.php?attachmentid=114349&d=1476830567)

The object “SwingOneHandedWeaponEvent” is a really simply C++ class derived from ItemEvent. No matter which class I pick here, I seemingly always get the “wrong class to spawn” error.

Am I going about this incorrectly? All I wish to achieve here is to initialize the variables that I include on my blueprint when the object is created at runtime, so when I access them later they are not null.

Any and all help would be greatly appreciated!
