I have some classes that ultimately derive from UObject. Now I want to create instances of said classes within a blueprint. For objects that are not actors, there is a ‘Construct Object fom Class’ node for that purpose.
However, I only get this blueprint compilation error:
I found a post on AnswerHub mentioning that the class must be directly derived from UObject, but even then I only get this error.
What am I missing here?
Any help is appreciated
The class must be marked as BlueprintType, since you want to use the result in blueprint. It’s a bit silly how it lets you select classes you can’t actually use.
@Zeblote
Awesome Works like a charm. Thanks.
And not only just with direct descendants of UObject (as the AH post suggested), but with any class ancestor that inherits from a ‘BlueprintType’ class.
Once I added ‘BlueprintType’ to my GameItem class, I can hold all kind of descendants in the array and identify them by their type
Yeah. If you omit the ‘BlueprintType’ specifier you cant select it as a parent in the BP wizzard dialog but here the class is just available for selection.
Also the documentation for that node is quite sparse (or I didnt look in the right places).
No, because add component is component specific, you can’t pass it a class to add. I ended up creating a C++ function that can take in a class and add it.
@crossmr Is it a blueprint node? If so, could you share your implementation? I have a project with different attack styles from unit to unit (ex. melee,range,AoE) but they’d all have an “Attack” component to reference in the rest of the code.