MeshCollider3D
Namespace:
namespace Lenga\Engine\Core;
class MeshCollider3D
MeshCollider3D uses a mesh or model asset as static triangle collision geometry. It is intended for authored environment pieces such as floors, ramps, terrain, race tracks, and level shells.
Properties
meshPath: project-relative path to the mesh or model asset used for collision.meshIndex: zero-based mesh index when the asset contains multiple meshes.offset: local offset from the GameObject transform.isTrigger: detects overlap without producing a solid collision response.materialPath: project-relative path to aPhysics Material 3Dasset.material: aPhysicsMaterial3Dobject representing the collider material.
Methods
getMeshCount
public function getMeshCount(): int
Returns the number of meshes loaded from the assigned mesh or model asset.
The value is 0 when no asset is assigned, the asset cannot be loaded, or the runtime has not resolved mesh data for this collider yet.
isTouching
public function isTouching(bool $includeTriggers = true, ?int $layerMask = null): bool
Returns true when this mesh collider is touching another matching 3D collider.
Set $includeTriggers to false to ignore trigger contacts. Pass a $layerMask to limit the check to colliders on matching GameObject layers.
getContacts
public function getContacts(bool $includeTriggers = true, ?int $layerMask = null): array
Returns the current Collision3D contacts involving this mesh collider.
Set $includeTriggers to false to return only solid contacts. Pass a $layerMask to limit results to matching GameObject layers.
Notes
For v1, use MeshCollider3D on static scene geometry. Moving actors should use primitive 3D colliders such as BoxCollider3D, SphereCollider3D, CapsuleCollider3D, or CylinderCollider3D.
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\MeshCollider3D;
final class TrackCollision extends Behaviour
{
public function start(): void
{
$collider = $this->getComponent(MeshCollider3D::class);
$collider->meshPath = 'Assets/Models/Track.glb';
$collider->meshIndex = 0;
}
}