World:newConvexCollider

Edit

Adds a Collider to the world and attaches a ConvexShape. A ConvexShape is a convex hull of a set of points, kinda like if you wrapped them in wrapping paper.











Arguments

NameTypeDefaultDescription
xnumber0 The x coordinate of the collider, in meters.
ynumber0 The y coordinate of the collider, in meters.
znumber0 The z coordinate of the collider, in meters.
pointstable A list of vertices to compute a convex hull from. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D point).
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the capsule, in meters.
pointstable A list of vertices to compute a convex hull from. Can be a table of tables (each with 3 numbers) or a table of numbers (every 3 numbers form a 3D point).
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
xnumber0 The x coordinate of the collider, in meters.
ynumber0 The y coordinate of the collider, in meters.
znumber0 The z coordinate of the collider, in meters.
modelDataModelData The ModelData to compute a convex hull from.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the capsule, in meters.
modelDataModelData The ModelData to compute a convex hull from.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
xnumber0 The x coordinate of the collider, in meters.
ynumber0 The y coordinate of the collider, in meters.
znumber0 The z coordinate of the collider, in meters.
modelModel The Model to compute a convex hull from.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the capsule, in meters.
modelModel The Model to compute a convex hull from.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
xnumber0 The x coordinate of the collider, in meters.
ynumber0 The y coordinate of the collider, in meters.
znumber0 The z coordinate of the collider, in meters.
meshMesh The Mesh to compute a convex hull from. It must use the cpu storage mode.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the capsule, in meters.
meshMesh The Mesh to compute a convex hull from. It must use the cpu storage mode.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

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

Arguments

NameTypeDefaultDescription
xnumber0 The x coordinate of the collider, in meters.
ynumber0 The y coordinate of the collider, in meters.
znumber0 The z coordinate of the collider, in meters.
templateConvexShape An existing ConvexShape to clone.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

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

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the capsule, in meters.
templateConvexShape An existing ConvexShape to clone.
scalenumber1.0 A scale to apply to the points.

Returns

NameTypeDescription
colliderCollider The new Collider.

Notes

This will throw an error if there are too many colliders in the world. The limit defaults to 16384 and can be changed in lovr.physics.newWorld.

See also