Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Initialize object of custom class from 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: https://docs.unrealengine.com/latest/INT/BlueprintAPI/Game/ConstructObjectfromClass/index.html

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

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!

Product Version: UE 4.12
more ▼

asked Oct 19 '16 at 08:30 AM in Blueprint Scripting

avatar image

78 7 20 24

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question