Hot reload not working

Hello I have a problem that hot reload isnt working at all. I added a minimal test case which “works” for me with UE 4.18.2 . I just put the actor on the map and nothing more. When I change some code in the TankPawn.cpp for example the

auto targetVector = FVector(5.f, 5.f, 970.f);

to some other numbers, I compile and nothing happens in the editor… also when I click play. I added the following code:

extern "C" {
	int
		__stdcall
		MessageBoxW(
			_In_opt_ void* hWnd,
			_In_opt_ const wchar_t* lpText,
			_In_opt_ const wchar_t* lpCaption,
			_In_ unsigned int uType);
}

// Sets default values
ATankPawn::ATankPawn()
{
	MessageBoxW(NULL, L"LOOL", L"LOOL", 0x00000000L);

to confirm that the object actually got reloaded… It gets called ( for me it also gets called 3 times or more, which is also strange because I have only one tankPawn in my map… but nevermind, this happened also in the standalone app, because the message box popped up 3 or more times. For me this is actually useless because I have to either shut down/reopen editor (which doesnt help), or delete, and add the pawn again into the map to make the code changes takes effect. I attached some code in the following link

EDIT1: It seems that the module is hot reloaded… but the params are NOT SET TO DEFAULT. When I open the properties editor I see my camera position and a small yellow arrow next to one of the params that I changed saying RESET TO DEFAULT. That is when I see the code I changed. Why this doesnt happen automatically? I didn’t change the settings in editor

Hi,

It might happen sometimes that Editor and Visual Studio fail to communicate with each other and hence the Editor will not get Hot Reloaded even if your code successfully compiles. Simply close the VS and open it again from inside the Editor and it should work fine (If they still fail to communicate, then simply close and reopen both of them.)

With regards to the Blueprint exposed variables not automatically resetting to their default - I believe this is the intended behavior of Blueprints. As a programmer, you create a base class, initialize its properties with some default values and expose them to Blueprints for your Designers to tweak them and build the rest of the gameplay. It would have been catastrophic if all these already changed and tuned variables reset to their defaults C++ set values once you recompile your code! So once you create a Blueprint based on a C++ class and change the value of a property, next time you compile, you have to manually link that property back to its default C++ value by clicking on that yellow arrow next to it.

Hope this answered your question.

Best,

Ahmad Jamialahmadi

Thank you, yes you are right… I fixed this catastrophic scenario by putting my NON-designer fields into BeginTick. I thought there would be some UProperty specifier to tell Unreal not to do this feature. Because there are use-cases where I don’t want this functionality but I am modifying a UProperty… for example I am trying to tweak a fixed camera component aiming at my tank from a fixed angle… this is not a designer editable thing in my case (my decision). Because in each level I want to have the same fixed angle, and when I update my module I want to have a different fixed angle…

If you want to prevent your designers from changing the variables in the editors, then either avoid exposing them to Blueprints at all or make them read-only for the Blueprints. To make them read-only simply mark them by UProperties VisibleAnywhere and BlueprintReadOnly and they cannot be changed in the Blueprints. If you want to go even further and make them project configurable and read-only even for your C++ classes, then you can give them a Config UProperty and make the variables read their values from one of your ~.ini files. Once a variable is marked with Config UProperty, it will become read-only and its value will not change at all (Though you will not get any kind of warning or compile error if you try to change its value. It will just ignore those changes and will not get affected). You can read about how to make a property Configurable in Unreal documentation here or briefly in my other answer here.

I have a CameraComponent that is somewhere under the RootComponent hierarchy… how can i tell not to expose the camera components local transform and local rotation ? I didnt specify to expose it… btw i attached code in the tankpawn.cpp in the attachment. CameraComponent is what i want to not be exposed