PhysicsMaterial2D
Namespace:
namespace Lenga\Engine\Core;
class PhysicsMaterial2D
Methods
fromArray
public static function fromArray(array $state, string $assetPath = '')
@param array{
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\Rigidbody2D;
class BouncyBall extends Behaviour
{
public function start(): void
{
$rb = $this->getComponent(Rigidbody2D::class);
// Create and configure physics material
$material = new PhysicsMaterial2D();
$material->density = 1.0;
$material->friction = 0.4;
$material->restitution = 0.8; // Bouncy!
// Apply material to collider
$rb->material = $material;
}
}