natiny.physics.mesh

Lua
natiny.physics.mesh(mesh) -> body

Creates a static body whose collider is a mesh, triangle for triangle.

Parameters

Name Type Description
mesh number Mesh handle, from natiny.mesh.load or a generated shape

Returns

Type Description
number Body handle, also usable as an entity handle

Example

Lua
local resource = natiny.resource.load("level.glb")
local level = natiny.mesh.load(resource)
local body = natiny.physics.mesh(level)

Notes

  • Every mesh part contributes triangles to one collider.
  • The mesh is read once, here. Destroying or changing it afterwards leaves the collider as it was.
  • The body is static and starts at the world origin. Vertex positions are interpreted in the body's local space.
  • Lua raises an error when physics is not running, the handle is not a mesh, or a collider cannot be built from its triangles.