C++ values not updated for existing objects in Unreal Editor

I’ve followed the tutorial:

and done all the steps, now I’m on my own.
But I still don’t understand ‘Why’ the C++ values I set is not being updated to the existing objects
in Unreal Editor?

If I make a Blueprint, all the existing objects update their value accordingly.
Example is:

USpringArmComponent* springArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("MyCameraAttach"));
springArm->SetupAttachment(RootComponent);
springArm->SetRelativeRotation(FRotator(-50, 0, 0));
springArm->TargetArmLength = 300.0f;
springArm->bEnableCameraLag = true;
springArm->bEnableCameraRotationLag = true;
springArm->CameraLagSpeed = 30.0f;

If I change the Rotator values, or TargetArmLength, the existing objects keeps their values. They don’t update to the new values. Unless I create new objects of the C++ class. Or as written above, create a blueprint out of the C++ class, put out objects made out of Blueprint, then change the values (and of course, expose USpringArmComponent as a UPROPERTY(EditAnywhere))

I don’t want to be able to change those values in Editor or Blueprint so it’s not a UProperty. I want it to be hardcoded in C++ side as I’m still learning. As you can see in the code above, it’s a local variable that just attaches itself to RootComponent.

I’ve also tried to use ‘PostInitProperties’ but it did not help.

Apparently though, changing my Static Mesh asset updates all the existing objects (which is also in the C++ side).
So how come my SpringArmComponent is not being updated?
Or is this intended?

EDIT:
I work by opening Unreal project first, and then opening Visual Studios.
So I do not upen the Unreal Editor by building it from Visual Studios.
Also, I usually build the Visual Studios project, rather than compiling it from Unreal Editor.
But compiling from Editor doesn’t seem to make any difference, other than that I have to use the mouse, instead of just using the Hotkey CTRL + B in Visual Studios.

The lines of code you provided, are those in constructor? Usually construction code is being run when you start editor or open the blueprint class. So if you are just compiling code without actually closing the editor it might not work.
I would recommend you to start your project from Visual Studio every time you make some changes to c++ code you want to check. Not doing so is pretty common reason of incorrect behavior.

Another recommendation of my own is to always, I mean ALWAYS add UPROPERTY() to any UObject* derived class. Even if they are declared private. You don’t have to add any specifires, just UPROPERTY(). It’s super important rule for correct work of unreal garbage collector.

I don’t see that reopening the project would be a realistic way of working with UE4 considering the time it takes to open it, even if it’s only 5-10 seconds. Just imagine opening the project 10 times, it’s already frustrating at that point.

And I remember reading in: Introduction to C++ Programming in UE4 | Unreal Engine Documentation
about hot reloading. And I’ve tried it several times, so it works. Just that the values aren’t updating ofc.

So yes, the values don’t really become updated, but as I learn more about UE4,
I think the proper way to develop in UE4 is to create C++ classes for high-performance logic and always derive the C++ with Blueprints, then set out the BPs as objects out in the world.
Please correct me if I’m wrong! I’m still a newbie so I don’t know the “proper” ways.

I’ve read about UPROPERTY() and that they would be garbage collected if they didn’t have the UPROPERTY. For anyone interested: Introduction to C++ Programming in UE4 | Unreal Engine Documentation
and search “Actors and Garbage Collection” for more info.

Might be the RootComponent holding them alive for now, since I called “SetupAttachment(RootComponent)” to it.

Great Tip though!

You might try setting a breakpoint in с++ constructor, to check at what time it’s called to see if on hotreload the values are being set at all. If they don’t that’s most likely is the reason why hotreloading do not work for changes in custruction.

Unfortunately restarting editor, when you deal with c++ code, is inevitable. I used hotreload a lot when I started working with unreal, but soon realized that I miss a lot of problems because sometimes it just don’t work the way you would expect.
For simple methods and some changes in logic inside it’s ok to hotreload, but when you add some new functions or, in your case, working with cunstructors, it might just not work.

As for using of c++ for heavy stuff instead of blueprints. Heavy stuff usually means you either do something in Tick() or when you have to handle huge arrays. For single shot events blueprints are totally ok, so don’t overdoo it. Besides some logic is much faster to write in blueprint and then move it to code. Especially on early stages of project development.