PhysicsMaterial3D

Namespace:

namespace Lenga\Engine\Core;

class PhysicsMaterial3D

PhysicsMaterial3D describes how a 3D collider responds when it contacts another collider.

Use it for surfaces that need distinct friction or bounce behavior, such as ice, rubber, stone, ramps, or collectible bumpers.

Properties

  • dynamicFriction: friction while bodies are already moving across each other.
  • staticFriction: friction used when bodies are trying to start sliding.
  • bounciness: restitution applied to contacts.
  • frictionCombine: how friction should combine with the other collider's material.
  • bounceCombine: how bounciness should combine with the other collider's material.
  • assetPath: the project-relative asset path when the material came from the editor asset workflow.

Methods

fromArray

public static function fromArray(array $state, string $assetPath = ''): self

Creates a PhysicsMaterial3D from collider state data.

Example

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\PhysicsMaterial3D;
use Lenga\Engine\Core\SphereCollider3D;

final class BouncyBall extends Behaviour
{
    public function start(): void
    {
        $collider = $this->getComponent(SphereCollider3D::class);

        $collider->material = new PhysicsMaterial3D(
            dynamicFriction: 0.2,
            staticFriction: 0.2,
            bounciness: 0.85,
        );
    }
}

For authored projects, prefer creating a Physics Material 3D asset in the editor and assigning it to the collider's Material field.