Change Mass in Runtime in C++

I’m trying to change the mass, and therefore the physical effects of a StaticMeshComponent with Phyisics enabled.
But for some reason I don’t understand, even when the Mass IS changed ( I’ve retrieved the mass value before and after), the phyisical object reacts in the same way.

Here is the piece of code that I use:

// Change Mass
float Mass = ShapeStaticMeshComponent->GetMass();
UE_LOG(LogTemp, Warning, TEXT(">>>> Starting Mass = %s"),*FString::SanitizeFloat(Mass));
ShapeStaticMeshComponent->GetBodyInstance()->bOverrideMass = true;
ShapeStaticMeshComponent->SetMassOverrideInKg(NAME_None,this->NewScale);
ShapeStaticMeshComponent->GetBodyInstance()->UpdateMassProperties();
Mass = ShapeStaticMeshComponent->GetMass();
UE_LOG(LogTemp, Warning, TEXT(">>>> New Mass = %s"),*FString::SanitizeFloat(Mass));

Am I missing something here?
Even in the wiki states this in a similar maner but it doesn work either for me:
ChangeMAss at runtime
This should be super basic in Physics, but it doesn’t seem to work.
Any code example you might have that works?

Thanks

What are you trying to do with the objects? Physics effects like gravity don’t depend on mass, so you won’t get any visible results unless you are using AddForce, AddImpulse or something similar.

Well, the weight force applied by gravity does depend on the mass of the object, right? I’m trying to create StaticMeshes during runtime and set up all its properties. And one of them is its mass. I want to be able to lets say set a cube mas to 100kg or to 1kg at runtime so that its innertia, weight ans so on changes.

Weight force does depend on mass, but acceleration due to gravity does not. The main time you’ll see a difference due to mass is when two physics-enabled objects bump into each other, or when you apply forces and impulses in code. If you are simply dropping two objects with different masses, they will accelerate and fall at the exact same rate.

Based on what you wrote above, it looks like the mass is being changed correctly. So if the behavior that you are seeing really is incorrect, then it could be a problem with how you are applying forces elsewhere in your code.

I understand its like the Hammer and feather experiment in the Moon ;). Would it be a good test if difference in mas if we lets say attach two different mas objects with a joint and move the one that we change the mass. If the effects on the other mas are different is a good test that we changed the mass?

ShapeStaticMeshComponent->AddImpulse(FVector(0.0f, 0.0f, ForceAmount));

Try binding this function to a key press, then put two different objects with different masses in the level. Whatever you insert for ForceAmount, make sure it is the exact same on both objects. Hit the key, and watch the objects jump. If the one with a smaller mass goes higher, then your mass is being set correctly. If they seem to go the same height and land at the same time, try making the mass difference between them much, much bigger. Then, if you still get the same result, something about the mass is not being set correctly, or it is getting reset somehow, and we can investigate.