Creating a 2 way teleport "Link"

I have the following code:


UCLASS()
class JAMES_API AJAMESBackdropLink : public AActor
{
	GENERATED_BODY()
	
public:	
	AJAMESBackdropLink();

	void OnConstruction( const FTransform& Transform ) override;

	UPROPERTY( EditAnywhere, BlueprintReadOnly, Instanced, Category = Backdrop )
	AJAMESTrigBoxBackdropChange* PointOne;

	UPROPERTY( EditAnywhere, BlueprintReadOnly, Instanced, Category = Backdrop )
	AJAMESTrigBoxBackdropChange* PointTwo;
	
};



AJAMESBackdropLink::AJAMESBackdropLink()
{
}

void AJAMESBackdropLink::OnConstruction( const FTransform& Transform )
{
	this->PointOne = new AJAMESTrigBoxBackdropChange();
	AttachRootComponentToActor( this->PointOne );

	this->PointTwo = new AJAMESTrigBoxBackdropChange();
	AttachRootComponentToActor( this->PointTwo );
}

I would like to make a blueprint instance of AJAMESBackdropLink and then have 2 instances of my trigger boxes inside this. I will then drag into my game, a AJAMESBackdropLink blueprint, then pull the trigger points “PointOne” and “PointTwo” to places in the scene, and then this will act as a two way teleport.

But the above code does not work.

What am i doing wrong?

Is “new” safe to use? I believe you might need to use (T*)GetWorld()->SpawnActor(T::StaticClass())

Check out:

https://forums.unrealengine.com/showthread.php?52410-What-is-the-correct-way-to-create-and-add-components-at-runtime

https://answers.unrealengine.com/questions/187297/how-to-spawn-a-blueprint-from-c.html

Thanks man, I actually sussed it out, i was not adding a RootComponent so i used a USceneComponent, iniitalised it with CreateDefaultSubobject, then converted my trigger boxes to UBoxComponents and attached those to my root component.