lovr.physics.newWorld

Edit

Creates a new physics World, which tracks the overall physics simulation, holds collider objects, and resolves collisions between them.

world = lovr.physics.newWorld(xg, yg, zg, allowSleep, tags)

Arguments

NameTypeDefaultDescription
xgnumber0 The x component of the gravity force.
ygnumber-9.81 The y component of the gravity force.
zgnumber0 The z component of the gravity force.
allowSleepbooleantrue Whether or not colliders will automatically be put to sleep.
tagstable{} A list of collision tags colliders can be assigned to.

Returns

NameTypeDescription
worldWorld A whole new World.

Notes

A World must be updated with World:update in lovr.update for the physics simulation to advance.

Example

Create a new world, add a collider to it, and update it, printing out its 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