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.
collider = World:newConvexCollider(x, y, z, points, scale)
collider = World:newConvexCollider(position, points, scale)
collider = World:newConvexCollider(x, y, z, modelData, scale)
collider = World:newConvexCollider(position, modelData, scale)
collider = World:newConvexCollider(x, y, z, model, scale)
collider = World:newConvexCollider(position, model, scale)
collider = World:newConvexCollider(x, y, z, mesh, scale)
collider = World:newConvexCollider(position, mesh, scale)
collider = World:newConvexCollider(x, y, z, template, scale)
collider = World:newConvexCollider(position, template, scale)
Arguments Name Type Default Description x number 0
The x coordinate of the collider, in meters.
y number 0
The y coordinate of the collider, in meters.
z number 0
The z coordinate of the collider, in meters.
points table
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).
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description position Vec3
The position of the center of the capsule, in meters.
points table
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).
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description x number 0
The x coordinate of the collider, in meters.
y number 0
The y coordinate of the collider, in meters.
z number 0
The z coordinate of the collider, in meters.
modelData ModelData
The ModelData to compute a convex hull from.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description position Vec3
The position of the center of the capsule, in meters.
modelData ModelData
The ModelData to compute a convex hull from.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description x number 0
The x coordinate of the collider, in meters.
y number 0
The y coordinate of the collider, in meters.
z number 0
The z coordinate of the collider, in meters.
model Model
The Model to compute a convex hull from.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description position Vec3
The position of the center of the capsule, in meters.
model Model
The Model to compute a convex hull from.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description x number 0
The x coordinate of the collider, in meters.
y number 0
The y coordinate of the collider, in meters.
z number 0
The z coordinate of the collider, in meters.
mesh Mesh
The Mesh to compute a convex hull from. It must use the cpu
storage mode.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
Arguments Name Type Default Description position Vec3
The position of the center of the capsule, in meters.
mesh Mesh
The Mesh to compute a convex hull from. It must use the cpu
storage mode.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
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 Name Type Default Description x number 0
The x coordinate of the collider, in meters.
y number 0
The y coordinate of the collider, in meters.
z number 0
The z coordinate of the collider, in meters.
template ConvexShape
An existing ConvexShape to clone.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
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 Name Type Default Description position Vec3
The position of the center of the capsule, in meters.
template ConvexShape
An existing ConvexShape to clone.
scale number 1.0
A scale to apply to the points.
Returns Name Type Description collider Collider
The new Collider.
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