Unreal engine behavior problem

In any constructor for any unreal engine class I have a problem I do not know how to handle when compiling in c++.

If I have within the constructor, a call to a function and pass a variable to that function from the constructor, I have found that when I have got everything working correctly and to my satisfaction, If I exit my session using Unreal Engine and return to continue, or I clean the solution or my project, Unreal engine crashes when I recompile or restart the editor. I have found that the problem seems to be that the Unreal engine is trying to run a function from the constructor with uninitialised parameters before they are defined in the constructor even though they are initialised before the function is called. I will illustrate with the following pseudo code example.

Class Constructor (){

variable = value;



unreal engine function(variable);
GEngine->AddOnScreenDebugMessage(-1, 1000.f, FColor::Green, FString::FromInt(variable);


If I try and run this when restarting the project, or cleaning the solution and project and recompiling the code, unreal engine editor will crash, or when trying to reopen…

However if I comment out the line


first in the constructor, recompile, the editor it will open.

Then if I uncomment the line


recompile, the editor will not crash and the code will operate as expected.

I have a suspicion this has everything to do with the hot reload of UE I have just wasted a lot of time thinking it was my code at fault until I remembered having this problem with using GEngine->AddOnScreenDebugMessage. to display variables and finding I had to comment these out before I leave a session and uncommenting them after restarting a new session, or cleaning the solution or project to continue. This is not desirable and time wasting.

So my question is, what, if anything can be done to stop the UE running functions from the constructor out of sequence of the code that is written and not pass variables without initialising them first as I have written in the code?

Or is this just an unreal engine thing and I have to comment out all function calls as I have found I have to do above to get the editor to open correctly each time I have finished a coding session and before recompiling?

I am sure this is something that is known, but I cannot find a solution online for.

Thanks in advance for any advice or help given. It would save me and perhaps others heaps of wasted time.


Hello IDominioNI,

I appreciate you providing such a descriptive question, and your use of pseudo code, however, in an effort to better investigate the issue and assist you, I would like to request the class .Cpp and .H file. I also believe you may find the following documentation of use. CompilingProjects, It includes some details and best practices on using Unreal’s hot reload system, as well as how to setup your build environment.


Thank you NicholasMont for your time and effort in replying to my problem. I am having problems in responding to you using the reply and add new comment buttons above. They don’t seem to be working when I press the comment button to submit my reply.

I am also having problems attaching the requested .h and .cpp files to this reply. I am getting a invalid file type error. so I will have to try and communicate the problem here

I have further investigated the current problem I have, and it may not be as I stated above. The variables I have been using to pass values to the function are strings of text specifying the path name to a mesh asset I am trying to load.

An example of line of code of calling the function within the game mode base constructor I am using as a test to see if I can load a static mesh before it is used and displayed is


and the function being called

  void AVirtual_WorldsGameModeBase::define_voxel_shapes_test(FString shape_name,FString shape_path_name){
    	UStaticMesh	 *voxel_mesh;
    	if (voxel_shape.Succeeded()) {
    		voxel_mesh  = voxel_shape.Object;
    	} else
    GEngine->AddOnScreenDebugMessage(-1, 1000.f, FColor::Green, "voxel_shape not Succeeded : " + shape_path_name);

The problem may actually be that the assets I am trying to load using the ConstructorHelpers::FObjectFinder are not being found by the editor, or it is something else I do not understand about how Unreal engine initialises and does things when starting up.

Everything complies just fine, but I am presently not being able to start the editor up at all after cleaning the solution and the project despite following the procedure mentioned above where commenting out function calls will solve things. I think the project may have become corrupted in some way. Fortunately I had backed it up just prior to stating my problem above, so I can recover the project if I can’t sort out what is going on. I am now clueless as to what is causing the problem I now have. Will get back when after trying to sort this out.


Greetings. I am now satisfied I have found what the problem is and this question can now be closed.

Selecting the clean solution option, and/or cleaning the project option within the build menu options of Visual studio is not a good idea. The fact that doing this previously and being able to get the unreal engine editor to fire up was fortunate. I am now experiencing a 100% failure rate and will avoid using this option unless absolutely necessary in future. It seems that there is a high degree of a risk in corrupting ones project in performing this task.

It seems that I was right in asserting that the ConstructorHelpers::FObjectFinder was not finding the static mesh assets I wanted to load. I thought that


was refering to the full project directory path name (where I have saved the mesh files I wish to use)


where in fact it looks to be referring to the full project path name


The files in this path name are not copies of the original mesh files as they are a fraction of the size of the mesh files I had copied and edited. In addition, there are two .uexp files that seem to be generated by the unreal engine editor as well. I am not going to elaborate on what I think these files do,except they are UE editor specific, critical to the function of UE, generated by the UE editor for its functioning, and therefore will need to follow the rule.

Don’t mess with the contents of the project directory


This is a valuable lesson that I will take into the future. When adding, editing, importing, or doing anything else with unreal engine assets, use the editor for all asset management and nothing else. To do otherwise will bring grief.

I am sorry and apologise if I have caused any misleading notions about the behavior of the unreal engine.

Best Regards