Hello I am new to UE4, from Unity where it is common to drag sister components into empty fields. In this case my component named “SpawnVolume4” has a field called “ParentOfSpawnedItem” and I would like to drag my component of the same name into that field. However, when I click the dropdown on the field, it only shows static objects (stuff in my contentbrowser) rather than items in my scene. What are some of my best options for connecting the component into the field? I am interested in both editor and code approaches.
(Red arrow shows the desired action. Commented code irrelevant.)
https://preview.redd.it/szc5rozb7tx41.png?width=1317
)
Wait, so you have a USceneComponent attached to your SpawnVolume4 object and you’ve named it ParentOfSpawnedItems. You also have a USceneComponent* called ParentOfSpawnedItems and you want it to point at the component that’s attached to your SpawnVolume4 object, is that correct? I think the easiest way to accomplish what you’re after is to assign the USceneComponent you’re attaching to your ParentOfSpawnedItems pointer at the time you attach it.
I’m guessing that in SpawnVolume4’s constructor, you have something that looks like this?
USceneComponent* MySceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("ParentOfSpawnedItems"));
if(MySceneComponent)
{
MySceneComponent->SetupAttachment(WhereToSpawn);
}
I’m just guessing, as I only see your .h
Instead, assign the component to the ParentOfSpawnedItems pointer and then attach it.
ParentOfSpawnedItems = CreateDefaultSubobject<USceneComponent>(TEXT("ParentOfSpawnedItems"));
if(MySceneComponent)
{
MySceneComponent->SetupAttachment(WhereToSpawn);
}
If you don’t expect to have to change the scene component at the end of that pointer after you’ve assigned it, it’s probably safe to remove that EditAnywhere specifier so it doesn’t show up in the details panel anymore.