Engine crash on startup when using SetMassOverrideInKg in constructor of actor

When you use SetMassOverrideInKg in the constructor of an actor, the engine crashes on startup.
If you add this functionality when the engine is already started, there is no problem.

The trace to the error:

UPrimitiveComponent::SetMassOverrideInKg ->
FBodyInstance::UpdateMassProperties ->
FBodyInstance::GetSimplePhysicalMaterial() ->
FBodyInstance::GetSimplePhysicalMaterial(const FBodyInstance* BodyInstance, TWeakObjectPtr<UPrimitiveComponent> OwnerComp, TWeakObjectPtr<UBodySetup> BodySetupPtr)

and then it’s the first line of the function:

check(GEngine->DefaultPhysMaterial != NULL);

so there is no DefaultPhysMaterial setup yet it seems.

Not sure if this is a bug or a feature, but I think it’s a bug…

Hey -

I followed the trail that you mentioned and found that at the check() line that you mentioned, the exception thrown is due to GEngine being null rather than DefaultPhysMaterial. This is because the engine is still being loaded and my not fully be loaded when the actor’s construction runs.


so is there going to be some kind of fix here? Because for developers, there is no reason to assume that you cannot call SetMassOverrideInKg in the constructor of an actor, yet it crashes the engine.

The simple solution for now would be to add if(GEngine) before the call to SetMassOverrideInKg() which will skip the function call when the editor loads and allow the project to open normally.

A bug report about the use of SetMassOverrideInKg in a constructor has been entered as well (UE-27425)