Why does changing the name of my camera make it not able to attach?

I generated a default ThirdPerson game and then I wanted to support other camera and movement modes. When I changed to first person the camera did not move as instructed. I ultimately figured out that the problem was I had renamed “FollowCamera” to “CharacterCamera” and that broke everything. I would like to know why because that doesnt make sense. All that changes was the string inside the TEXT() call:

Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));

Was changed to:

Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CharacterCamera"));

And this broke:

// in SetupThirdPersonCamera()
Camera->AttachToComponent(CameraBoom, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName);

// in SetupFirstPersonCamera()
Camera->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("head"));

Changing it back fixed it but I would REALLY love to know why.

What broke was the saved property values in the blueprint, which use the component name to figure out how to read back the data. These names are part of how C++ and Blueprint talk to each other.

You have to re-create a new blueprint when you change the base component names, OR at least load the old blueprint, and press “revert to defaults” on each of the properties, and then configure them the way you want them.