Modifying C++ Base Class Resets Derived Blueprint's Variables to Default after Editor Compile

I’m experiencing an issue in 4.18.1 which causes blueprint variables to reset to default values in the editor when the base C++ class’s header file is changed with by adding a comment. The following steps always reproduce the issue:

  1. Launch 4.18.1 and create a new C++ 2D Side Scroller project
  2. Open the visual studio project from the Unreal Editor if it is not already open. I’m using Visual Studio 2015.
  3. Open MyProjectCharacter.h
  4. Add a public member variable with a UPROPERTY
    UPROPERTY(Category = "Test Variables", EditAnywhere, BlueprintReadOnly)
    int m_nTestVar UMETA(DisplayName = "Test Var");
  5. Open MyProjectCharacter.cpp
  6. Initialize m_nTestVar to 0 in AMyProjectCharacter’s constructor
  7. Go to the Unreal editor and compile
  8. In the World Outliner tab select TP_2DSideScrollerCharacter
  9. In the Details tab, find the Test Variables category and set Test Var to a non-zero number
  10. In the editor, File > Save All
  11. In MyProjectCharacter.h, add a comment above the m_nTestVar’s UPROPERTY
    //A comment
    UPROPERTY(Category = "Test Variables", EditAnywhere, BlueprintReadOnly)
    int m_nTestVar UMETA(DisplayName = "Test Var");
  12. Go to the Unreal editor and compile
  13. Test Var is reset to its default value.

If the above steps do not reset the value then follow the next steps:

  1. Add a second variable, m_nTestVar2, in MyProjectCharacter.h and initialize it to zero in the constructor as well. The exact same thing as m_nTestVar
  2. Go to the Unreal editor and compile.
  3. Test Var is reset to its default value.

I’ve tried these step in 4.16.3, and the issue does not exist in that older version. The variables always retain their blueprint value regardless of the number of comments and new variables I add the to base class’s header file.
Is 4.18.1 exhibiting the intended behavior or is this a bug? If this is intended, is there a way to retain the 4.16.3 behavior? 4.18.1 is not usable for me due to this issue.

Hey Hoboic-

This is a known issue that has been reported here: Unreal Engine Issues and Bug Tracker (UE-52220) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.


Would there be any workaround? Like compiling form VS without any hotreloading or something? Since this is a pretty bad buster if you have to work with C++ extensively.

Yes, closing the editor before compiling (avoiding the hot reload process) will compile the code without affecting variable values.

Compiling it inside VS manually and starting the editor after would work? Am I correct?

And is there any way to disable code hot reloading?

Thanks a lot!

Yes, compiling from Visual Studio with the editor closed should work for you. There is no way to disable hot reloading. Hot reload is the process the editor uses to update code changes with the editor still open.

Great thanks a lot! But other people developing with a C++ back/end have encountered this right? There are a ton of games out there that depend on C++ rather than blueprints.

Sorry for being unclear.

  1. Thank you for the workaround, it is usable for the moment.

  2. In my game (a RPG) we have a lot of NPCs with a C++ base class called ‘ARPGNPC’. Any time that I modify the base class all the blueprints that depend on that class get their data reset, and for a lot of NPCs that is very bad. I am sure that other people developing games usually use base C++ classes and have the same problem? And that would mean this problem is, maybe, higher on the priority list?

Anyway, another workaround would be storing per-NPC data for each of them in a separate database and load the info at runtime, so that it is not dependent on the blueprint settings. But again, that would mean adding the extra database layer instead of simply using the built-in blueprint system, and would mean more time/effort from the side of the programmers, and that is why I hoped for a unreal team fix.

I hope everything is clear now.

I’m not sure I understand your question. Can you elaborate on what you’re trying to accomplish, please?


I have just tested this, I made modifications to my C++ NPC class (added some field ‘bIsLoosingDataAgain’) and I’ve re-compiled with the editor and the data was not lost.

I’ve followed the steps:

  1. Open VS(from it’s project list NOT UE!)
  2. Compile inside VS with the editor closed
  3. Open the editor, the changes should appear and the data is not lost
  4. If you didn’t opened VS from UE you can’t press the compile button inside the editor or if you do no data is going to be updated. You have to restart the editor each time

I find this workaround quite cumbersome, tiring and hacky. I’m sure the guys at fortnite, paragon or senua really did not work like this.

Thanks for the responses. I tried compiling with the editor closed, then re-opening the editor. The derived blueprints did not contain any of the updates made to the c++ base class, in this case a new member variable. Proceeding to compile in the editor still reset all values, as expected, but did update the blueprints to have the new variable.

Is the part of the editor/engine responsible for updating blueprints accessible from github? If so, would you know which source files I should look at? If it’s not going to be fixed anytime soon I wouldn’t mind trying to fix it myself… or make it worse.

Currently the only feasible workaround is stay at version 4.16.3, which is not ideal in the long run.

Thanks for listing those steps. I was indeed opening VS from UE, which was one of the issues. The other was that my solution configuration was set to DebugGame Editor, which does not delete the old hot reload files, instead of Development Editor.

I’ll definitely forget to close the editor before compiling in the future.


Found a workaround for accidentally compiling with the editor still open. For this example, I’m compiling for Win64 with the project name TestProj

  1. Make a change to the base C++ class in VS with UE open.
  2. Compile in UE.
  3. Close UE
  4. Go to project directory TestProj\Binaries\Win64
  5. Delete the hot reload files in the naming format
    The -####, in this case -6760, indicate its a hot reload file. Do not delete the normal files in the naming format
  6. Open UE
  7. A popup stating
    The following modules are missing or built with a different engine version: …
    will appear. Click Yes to rebuild.
  8. The blueprints regain there old saved values and have the update from the c++ base class.

This lets me recover something at least.

Well, it still implies the fact that you will have to open/close the editor and for a lot of C++ tweaks this can become cumbersome and you have to build 2 times.

Let’s hope that in 4.20 we’ll have a fix :slight_smile:

Any updates?

The issue is still ‘unresolved’. Unreal Engine Issues and Bug Tracker (UE-52220)

It’s quite important, I wonder how other people using C++ with UE solve this, since for me it’s a key-feature. Maybe people have custom DB-s loading that data.

I have this issue as well. I would really prefer to be able to not have my values in BP from compiling in C++ to empty/default themselves. It’s been an annoyance for some time now in 4.18

Yea, it’s weird this is not handled. I wonder all the guys that use UE have their variables in the Blueprint side of things?

Have you guys test 4.19 to see if its fixed there ? - I just noticed this issue myself, and even though I am still in the very beginning of my project, I’d see this becoming a major hindrance if someone forgets to close down the editor while compiling having all the properties reset to its default values if you’re using a lot of blueprints deriving from that class :confused:

Personally I like to keep my variables in C++ as I find it easier to manage there D:

Same here. The issue still seems to be unresolved, even though I think it’s quite important. I wonder every studio out there manages their variables in the blueprint side? I’d find it rather odd.

And yea, don’t forget to go to the issue and vote for it.

OMG how this is not resolved yet! Hopefully I have noticed the issue and was able to restore my blueprints from the version system, but it’s a blocker issue, actually.