Code works and then doesn't work and then works again without changing anything, what am I doing to cause this?

I have this code:

AFPSChar::AFPSChar()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;

GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f,0.0f);
GetCharacterMovement()->JumpZVelocity = 600.0f;
GetCharacterMovement()->AirControl = 0.2f;

cameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("cameraBoom"));
cameraBoom->SetupAttachment(RootComponent);

cameraBoom->TargetArmLength = 300.0f;
cameraBoom->bUsePawnControlRotation = true;

followCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("followCamera"));
followCamera->SetupAttachment(cameraBoom, USpringArmComponent::SocketName);
followCamera->bUsePawnControlRotation = false;

}

Worked beautifully last night, so I saved everything, closed it, went to bed, woke up in the morning, opened everything up, tested it again, literally nothing worked. So I commented out all the lines of code that aren’t default in the class, added them back in one by one compiling and testing each time, lo and behold without changing anything my code works again.

I’m sure tomorrow it will break itself again. WTF??!?!?!?!?! I have never seen a coding program that will work and then break without me changing anything. I want to say it’s user error, but I just cannot see how it could be, when changing nothing still causes it to oscillate between broken and not broken.

PLEASE, someone tell me what I am doing wrong because it seems to me like I have to force UE4 to remember my lines of code constantly, and it’s not actually a problem with the code itself.

It’s likely a caching issue you are running into based on the provided code, but it could be caching or a race condition if the issue is intermittent.

When you say nothing is working what do you mean, like it won’t compile at all? It crashes when you hit play? The character just doesn’t move? Do you have any logs/errors/warnings showing up? Have you tried commenting out each line one by one to to try and isolate which line is causing the problem.