Hi, first, let me give a little explanation of what I want to accomplish:
I want to add multiple components (both SceneComponents and ActorComponents) to my Actor Blueprint, programmatically, before using it. These components are used for gameplay logic.
For example:
Starting with the following actor:
Actor
Actor └─RootComponent ├─Group1 │ └─StaticMesh1 └─Group2 └─StaticMesh2 └─ActorComponent1
I can create a Blueprint based on it using FKismetEditorUtilities::CreateBlueprintFromActor
. This would give me the following blueprint:
Blueprint
Blueprint └─RootComponent ├─Group1 │ └─StaticMesh1 └─Group2 └─StaticMesh2 └─ActorComponent1
Let’s say I wanted to add a gameplay component as parent of group 1 like so:
Added gameplay component
Blueprint └─RootComponent ├─GameplayComponent1 │ └─Group1 │ └─StaticMesh1 └─Group2 └─StaticMesh2 └─ActorComponent1
To add such a component to an actor, I would simply get its root component, find the ‘Group1’ component, and add my gamplay component as a parent (making sure to add it as children of the old parent, in this case RootComponent).
I haven’t found any straight forward way to do so inside the BP.
Here is what I tried:
-
Modifying the generated class’s CDO. While this looks like an easy and straight forward solution, I did not find any way to access the component hierarchy from the CDO (it has no components).
-
Modifying the SCS. This worked to an extent, but is way too complicated. This should be a last resort.
-
Adding the components prior to converting to a blueprint: this was my initial approach, but I realized that the references I added inside those component were invalid after the conversion. Trying to fix the references is as bad as adding the components themselves.
If anyone of you knows a way to do this, or knows how to easily manipulate a SCS and USCS_Nodes, please help me.
Thanks a lot in advance.