Static Mesh Component appears in the wrong place in game

For some reason when creating a static mesh component via c++ it won’t spawn in the correct location in game. My code is pretty basic so hopefully I’m just missing something obvious.

In my header file I have this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
	UStaticMeshComponent* HighlightMesh;

And in the cpp file:

HighlightMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("HighlightMesh"));
HighlightMesh->SetupAttachment(RootComponent);

Here is the view in the derived Blueprint.

And in the game view.

Whenever I duplicate the inherited mesh component I can actually get the blue square in the game view. Which leads me to believe that its just something funky with my code.

Any ideas?

Have you tried AttachToComponent with an AttachmentTransformRule?

Turns out it was just a hot reload de-sync between c++ and blueprint. I had to delete the old blueprint that was in the scene and add it again to get it working. Makes sense as I really didn’t see anything wrong with my code.