In this lesson, you will learn how to fine-tune the physical behavior of your actors by adjusting mass, friction, and restitution properties within the Chaos Physics engine.
When you enable Simulate Physics on an actor, Unreal Engine hands control over to the Chaos solver. To make objects behave realistically—like a heavy bowling ball versus a bouncy rubber one—you must configure three core properties found in the Physics section of your actor's details.
Understanding the Physics Trio
- Mass (Mass In Kg): This dictates how much force is required to move the object. In Unreal, if you don't manually set a mass, the engine calculates it automatically based on the object's volume and the density of its material. If you need a small rock to feel incredibly heavy, you can manually override this value to force a specific weight.
- Friction: This determines how much the object "grabs" the surface it slides against. A value of
0makes an object slippery like ice, while a high value (like1.0or greater) makes it feel like sandpaper, causing it to stop quickly when it hits the ground. - Restitution (Bounciness): This defines how much energy is conserved during a collision. A value of
0means the object hits the floor and stops dead (like a lump of clay), while a value of1means it bounces back with full force.
Practical Implementation
While you can set these in the Editor, you can also modify them via C++ or Blueprint if you want objects to change properties dynamically (e.g., a "sticky" power-up). If you are using a UPrimitiveComponent, you can adjust these settings at runtime like this:
// Accessing the physics settings of a component
UPrimitiveComponent* MyMesh = GetMesh();
if (MyMesh)
{
MyMesh->SetMassOverrideInKg(NAME_None, 100.0f);
MyMesh->SetPhysMaterialOverride(MyBouncyMaterial);
}
By tweaking these three parameters, you define the "personality" of your physical objects, allowing them to react naturally to impacts, gravity, and player interaction within your level.
Key Takeaway: Mass, friction, and restitution are the fundamental variables that translate raw physics calculations into believable, distinct object behaviors in your game world.