Heya,
First of all, I’m new to Unreal, so still learning.
I have a procedural generation tech built in C++ that basically combines different actors at their skeletal mesh’s different socket locations.
A good analogy would be Rooms. I have a different mesh with sockets for each Room, and each Room has a Room_BP with the static mesh and some triggers etc.
I also have a House Generator in C++ that procedurally can create interesting houses out of a combination of rooms.
I have an Actor Blueprint (House_BP) that contains a C++ Component HouseGenerator.
The House_BP has an Array of Soft Class Pointers that I configure with the different available Room_BP’s for that House.
This array is then received in C++ like so:
void
UtestActorComponent::PassingActorsToCpp(TArray<TSoftClassPtr<AActor>> theActors)
{
for (TSoftClassPtr<AActor> actorPtr : theActors)
{
FString name = actorPtr.ToString();
auto actor = NewObject<AActor>(GetTransientPackage(), *name);
// Get all components attached to the actor
TArray<UStaticMeshComponent*> Components;
actor->GetComponents(Components, true);
// Print the class names of all components
for (UActorComponent* Component : Components)
{
UE_LOG(LogTemp, Log, TEXT("Component class: %s"), *Component->GetClass()->GetName());
}
continue;
Now, I’d expect actor->GetComponents() to list the components that are defined in the Blueprint Actor. But it is empty.
The Room BP that was sent to C++ does in fact have components:
And eventually all I need to achieve is to extract the Sockets setup in the Static Mesh before passing along control to my own procedural generation code.
I’m obviously missing something obvious but I can’t figure out what…
My plan is for a designer to setup the available rooms from a blueprint, kick it off to my C++ generation code that uses the known sockets and available rooms to give back a list of rooms that will be instantiated from within the blueprint.
Perhaps this plan is just plain stupid, I don’t know But seriously, why can’t I get the components from the blueprints so I can query it for Sockets?
Thanks in advance!