Engine always crashes on start

As the title tells, everytime I open the engine it crashes and this is the crash log:

The arrows are pointing to the string that tells the directory of the suspected files that cause the crash.

Weapon.cpp [17]

MyProjectCPPCharacter.cpp [57]

I suspect there’s a problem creating the CurrentWeapon variable dynamically.

In fact, if I create the object on the stack (statically) the Engine doesn’t crash.

Hello gedamial,

From the callstack, the first line shows a .cpp files and a line of the code from the source code (UObjectGlobals.cpp line 2071.) When navigating to this line in Visual Studio, it’ll reveal that the reason for the crash was “UObject() constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you trying to construct it on the stack which is not supported.”.

This would mean that you are on the right track with line 57 of your MyProjectCPPCharacter being the problem. Have you tried using NewObject instead of the “new” macro?

We haven’t heard from you in a while, gedamial. Are you still experiencing this issue? If so, please let me know if you’ve had a chance to try my suggestion from my previous comment. In the meantime, I’ll be marking this issue as resolved for tracking purposes.

I just took a look at ShooterGame example and saw how things should be done.

Never use NEW dynamic allocation with UE4 (damned)