Create the Asset
In the Assets panel:
- Right-click the folder where you keep physics assets.
- Choose
Create > Physics Material 3D. - Name the asset for the surface behavior, such as
RubberBall,IceRamp, orStoneFloor.
Select the asset to edit its values in the Inspector.
Tune the Surface
Start with these fields:
Dynamic Friction: how much moving contact resists sliding.Static Friction: how much resting contact resists starting to slide.Bounciness: how much velocity is preserved after impact.Friction Combine: how this material combines friction with the other collider's material.Bounce Combine: how this material combines bounciness with the other collider's material.
A rubber ball usually has lower friction and higher bounciness. A stone floor usually has moderate friction and low bounciness. Ice usually has very low friction.
Assign It To a Collider
Select a GameObject with a 3D collider.
In the collider card, set Material to your Physics Material 3D asset.
The supported 3D collider components are:
BoxCollider3DSphereCollider3DCapsuleCollider3DCylinderCollider3DMeshCollider3D
Press Play and test the result. If the behavior is too strong, tune the material asset instead of editing each collider separately.
Use It From Code
You can assign a material asset path when the collider should switch surfaces at runtime.
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\SphereCollider3D;
final class BallSurface extends Behaviour
{
public function start(): void
{
$collider = $this->getComponent(SphereCollider3D::class);
$collider->materialPath = 'Assets/Physics/RubberBall.physics-material3d.json';
}
}
For most authored scenes, use the Inspector field. Use code when the gameplay intentionally changes the material during play.