Why isn't my component attaching properly?

I’m testing around with creating/initializing components during runtime but found that the components aren’t attaching at all and I don’t know why?

Currently using this:

void AMainCharacterTesting::Test()
{
	if (!TestArrow)
	{
		TestArrow = NewObject<UArrowComponent>(this, "TestArrowComponent");
		TestArrow->RegisterComponent();
		TestArrow->SetupAttachment(Camera);
	}
}

Thanks in advance.:slight_smile:

SetupAttachment can only be called in the constructor (CDO)

You can use AttachToComponent
So

TestArrow->AttachToComponent(Camera,FAttachmentTransformRules::KeepRelativeTransform)

Ofc you can have more refined control with the FAttachmentTransformRules as a parameter and set it more in depth.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.