World:newMeshCollider

Edit

Adds a Collider to the world and attaches a MeshShape.

Colliders with mesh shapes are immobile and can only be used for static environment objects. The collider will be kinematic and forces/velocities will not move it. Also, these colliders will not detect collisions with other kinematic objects.

MeshShapes are not treated as solid objects, but instead a collection of triangles. They do not have mass or volume, and there is no concept of being "inside" a mesh. ConvexShape is a good alternative for solid objects with an arbitrary shape.






Arguments

NameTypeDescription
verticestable A table of vertices in the mesh. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D vertex).
indicestable A table of triangle indices representing how the vertices are connected together into triangles.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDescription
modelDataModelData A ModelData to use for the mesh data.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDescription
modelModel A Model to use for the mesh data. Similar to calling Model:getTriangles and passing it to this function, but has better performance.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDescription
meshMesh A Mesh to use for the mesh data. It must use the cpu storage mode.

Returns

NameTypeDescription
colliderCollider The new Collider.

Clones an existing MeshShape, which is faster than passing the same mesh multiple times. Clones can have their own scale. The clone's scale doesn't get multiplied with the scale of the template.

Arguments

NameTypeDescription
templateMeshShape An existing MeshShape to reuse.

Returns

NameTypeDescription
colliderCollider The new Collider.

Notes

The triangles in a MeshShape should use counterclockwise winding.

See also