World:newCollider

Edit

Adds a new Collider to the World.



Arguments

NameTypeDefaultDescription
xnumber0 The x position of the Collider.
ynumber0 The y position of the Collider.
znumber0 The z position of the Collider.

Returns

NameTypeDescription
colliderCollider The new Collider.

Arguments

NameTypeDescription
positionVec3 The position of the Collider.

Returns

NameTypeDescription
colliderCollider The 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