# SetMassOverrideInKg crashes Engine

**URL:** <https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703>\
**Category:** World Creation\
**Tags:** Physics-Mass, unreal-engine, crash, bug-report, CPP, question\
**Created:** [November 26, 2015, 3:56am UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703 "2015-11-26T03:56:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Celebi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benjamin\_Celebi](https://forums.unrealengine.com/u/Benjamin_Celebi)\
**Post date:** [November 26, 2015, 3:56am UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/1 "2015-11-26T03:56:33Z")

</div>

Everytime i add “SetMassOverrideInKg” to my code, to change the mass of an object, the engine crashes immediatly on launching, when i open the same projekt again.  
Happend to two of my projects now. Any help ?

Here the log:  
MachineId:8FFB77F549FD8EEA6354A989FF53F812  
EpicAccountId:ce7253c5dacf49ce8fd6317ecab4654a  
Access violation - code c0000005 (first/second chance not available)  
“”  
UE4Editor\_Engine!FBodyInstance::GetSimplePhysicalMaterial() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\physicsengine\bodyinstance.cpp:2998]  
UE4Editor\_Engine!FBodyInstance::UpdateMassProperties() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\physicsengine\bodyinstance.cpp:3135]  
UE4Editor\_Engine!UPrimitiveComponent::SetMassOverrideInKg() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\primitivecomponentphysics.cpp:498]  
UE4Editor\_Godless\_4976!ACreature::ACreature() [c:\users\user\documents\unreal projects\godless\source\godless\creature.cpp:20]  
UE4Editor\_CoreUObject!UClass::CreateDefaultObject() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\class.cpp:2657]  
UE4Editor\_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:658]  
UE4Editor\_CoreUObject!ProcessNewlyLoadedUObjects() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:752]  
UE4Editor\_CoreUObject!TBaseStaticDelegateInstance::ExecuteIfSafe() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl\_variadics.inl:921]  
UE4Editor\_Core!TBaseMulticastDelegate::Broadcast() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegatesignatureimpl\_variadics.inl:809]  
UE4Editor\_Core!FModuleManager::LoadModuleWithFailureReason() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\core\private\modules\modulemanager.cpp:426]  
UE4Editor\_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\projects\private\moduledescriptor.cpp:370]  
UE4Editor\_Projects!FProjectManager::LoadModulesForProject() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\projects\private\projectmanager.cpp:53]  
UE4Editor!FEngineLoop::LoadStartupModules() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:1989]  
UE4Editor!FEngineLoop::PreInit() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:1495]  
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launch.cpp:110]  
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]  
UE4Editor!WinMain() [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]  
UE4Editor!\_\_scrt\_common\_main\_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe\_common.inl:264]  
kernel32  
ntdll

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 27, 2015, 7:07pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/2 "2015-11-27T19:07:21Z")

</div>

Hey Benjamin-

How are you using the SetMassOverrideInKg function in your code? What kind of component are you calling the function on? Could you post the code class where SetMassOverrideInKg is being called?

Cheers

---

<div class="post-metadata">

**Author:** ![Benjamin\_Celebi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benjamin\_Celebi](https://forums.unrealengine.com/u/Benjamin_Celebi)\
**Post date:** [November 28, 2015, 2:24pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/3 "2015-11-28T14:24:02Z")

</div>

Hey,

here is the code, i just created a new actor. The header file is unchanged. As soon as i save this, compile it, and restart the project, it crashes.

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "Godless.h"
#include "Test.h"

// Sets default values
ATest::ATest()
{
 	// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	//Setup the mesh
	UStaticMeshComponent* mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
	ConstructorHelpers::FObjectFinder<UStaticMesh> VisualAsset(TEXT("/Game/BasicShapes/Cylinder"));
	if (VisualAsset.Succeeded())
	{
		mesh->SetStaticMesh(VisualAsset.Object);
		mesh->SetSimulatePhysics(true);
		mesh->SetMassOverrideInKg("", 1.0);
	}
}

// Called when the game starts or when spawned
void ATest::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ATest::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 30, 2015, 3:17pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/4 "2015-11-30T15:17:33Z")

</div>

Hey Benjamin-

I believe the cause of the crash is the empty BoneName string. In this case there is no way of knowing what bone is being referred to so the editor doesn’t know what to do with the function call. If you make the same function call on a skeletal mesh (rather than static mesh) and specify a specific bone in the call there should be no crash.

Cheers

---

<div class="post-metadata">

**Author:** ![Benjamin\_Celebi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Benjamin\_Celebi](https://forums.unrealengine.com/u/Benjamin_Celebi)\
**Post date:** [November 30, 2015, 10:24pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/5 "2015-11-30T22:24:39Z")

</div>

Thanks a lot, is there any way to change the mass on a static mesh ?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 1, 2015, 2:40pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/6 "2015-12-01T14:40:02Z")

</div>

If you make a blueprint based off of your class and select the static mesh component, there is a checkbox in the details panel that will override the mass and allow you to set the mass you want the mesh to have. You can change the mass per instance of the static mesh after placing it in the level in the same way.

---

<div class="post-metadata">

**Author:** ![ProzackPH7](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/prozackph7/32/597366_2.png) [@ProzackPH7](https://forums.unrealengine.com/u/ProzackPH7)\
**Post date:** [January 26, 2016, 10:18am UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/7 "2016-01-26T10:18:44Z")

</div>

So is there no way to set static mesh Mass manually through blueprints (Say adding mass overtime)? Because Im creating containers that actually become heavier as things are added to it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [January 26, 2016, 4:00pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/8 "2016-01-26T16:00:26Z")

</div>

Hey ProzackPH7-

Using the static mesh as the target you can add a Set Mass Override in Kg node and set the new mass. Be sure to also check the box for Override Mass so that the value that you set will be recognized.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6fcbe82e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6fcbe82e](https://forums.unrealengine.com/u/anonymous_user_6fcbe82e)\
**Post date:** [February 23, 2016, 10:21pm UTC](https://forums.unrealengine.com/t/setmassoverrideinkg-crashes-engine/339703/9 "2016-02-23T22:21:59Z")

</div>

Actually I’m looking into this problem as well, but then in C++. The crash only happens when you first start the engine with a SetMassOverrideInKg in the constructor.  
If you add the SetMassOverrideInKg after the engine already started, then there is no problem.  
This is the SetMassOverrideInKg function:

```
if (FBodyInstance* BI = GetBodyInstance(BoneName))
	{
		WarnInvalidPhysicsOperations(LOCTEXT("SetCenterOfMass", "SetCenterOfMass"), nullptr);
		BI->bOverrideMass = bOverrideMass;
		BI->MassInKg = MassInKg;
		BI->UpdateMassProperties();
	}

```

Not sure about the WarnInvalidPhysicsOperations, but then it goes into UpdateMassProperties, which goes directly into GetSimplePhysicalMaterial, which gives the problem:

check(GEngine-\>DefaultPhysMaterial != NULL);

and there’s the error. So it seems that there is no DefaultPhysMaterial set in the GEngine when you start the engine. I don’t know if this is a bug, but I’ll report it anyway.

A temporary solution would be to not call the SetMassOverrideInKg in the constructor, but rather in BeginPlay or something like that…
