Download

Components parent changing in subclass of C++ defined Pawn after reload

Ok so I’ll try to make sense here…

My base pawn is defined in C++. I create the components, attach them, etc.
I then have a Blueprint that is a child of that C++ class (not sure if the subclassing is relevant).

When I pull this up initially in engine, it looks fine and the parenting is correct:
ue4_before.png

After quitting the engine and relaunching however, the parenting on that RightHandWidget there is lost and I get this:
ue4_after.png
(see how the RightHandWidget is now parented by the RootComponent instead)

Completely baffled here…
If I reparent to a Pawn and then back to my C++ defined class it works fine, until next time I relaunch the engine.
Not sure if this belongs here or in the Blueprint forum but since the base code is C++ figured I’d start here…

In the CPP file of your own Pawn class, in the constructor, do you do:


RightHandWidget->SetupAttachment(RightMotionController);

That is, sadly, exactly what I had. However I’ll close this out (if I can?) as I think it’s a blueprint issue, not C++ related…
I moved the custom code from the blueprint subclass into C++ code and it’s all working fine.

Did you initially have the Component in the Blueprint and then you added it to C++ with the same name before changing it in blueprints? I have had issues with this before.

The components were all only in C++. The only thing the Blueprint subclass was doing was initializing some variables in the Pawn, as well as adding some debugging visuals (a plane with debug text on it). Like I said above, I ditched the blueprint and moved it all to C++ to solve it.