World:newCollider

Adds a new Collider to the World.

collider = World:newCollider(x, y, z)

Arguments

NameTypeDefaultDescription
xnumber0The x position of the Collider.
ynumber0The y position of the Collider.
znumber0The z position of the Collider.

Returns

NameTypeDescription
colliderColliderThe new Collider.

Notes

This function creates a collider without any shapes attached to it, which means it won't collide with anything. To add a shape to the collider, use Collider:addShape, or use one of the following functions to create the collider:

Example

Create a new world, add a collider to it, and update it, printing out the collider's position as it falls.

function lovr.load()
  world = lovr.physics.newWorld()
  box = world:newBoxCollider()
end

function lovr.update(dt)
  world:update(dt)
  print(box:getPosition())
end

See also