Construct Object From Class - "Wrong class to spawn" error - Initializing objects via blueprint

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 | Unreal Engine Documentation

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

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!

Construct Object will only create anything derived from UObject, up until a certain point (Like Actor cannot be spawned from Construct Object). Which base class does ItemEvent come from?

It’s derived from ActorComponent. Is that not valid?

I haven’t used the Add x Component node before, but I think it is the node that you’re looking for. Simply type in the context menu: Add SwingOneHandedWeaponEvent component.

Samples of my own actor components written in C++ (The add nodes were auto generated): http://puu.sh/rONPo/236664ca5f.png

Great - that set me on the right track. I simply needed to expose my cpp classes to be blueprint spawnable and that node then became available. Thanks