I’ll attempt to break this down as simple as possible so the issue is clear.
I have AGameCharacter.cpp that inherits from ACharacter.
AGameCharacter has a USpringArmComponent and a UCameraComponent that get created in the Constructor. The camera is parented to the spring arm:
AGameCharacter.h
/** Side view camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* SideViewCameraComponent;
/** Camera boom positioning the camera beside the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
AGameCharacter.cpp
AGameCharacter::AGameCharacter()
{
// Create a camera boom attached to the root (capsule)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
// Create a camera and attach to boom
SideViewCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("SideViewCamera"));
SideViewCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
}
I create a blueprint CharacterBP that inherits from AGameCharacter.cpp.
When I change AGameCharacter.cpp such that the camera is now parented to the RootComponent, CharacterBP doesn’t reflect this change. The blueprint editor will not let me reparent them to match what the parent class defines. This seems to only be fixable by commenting out CreateDefaultSubobject for the spring arm and the camera, compiling, then uncommenting them out and recompiling again. Its also fixable by reparenting CharacterBP to a different class then parenting it back. Both incur data loss and are really inconvenient.
Is there something I’m not understanding about the relationship between blueprints and the C++ classes they inherit from? Is the Constructor somehow only ever called once for the blueprint and thus the parenting is a one action?