lovr.physics.newWorld
EditCreates 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
Name | Type | Default | Description |
xg | number | 0 | The x component of the gravity force. |
yg | number | -9.81 | The y component of the gravity force. |
zg | number | 0 | The z component of the gravity force. |
allowSleep | boolean | true | Whether or not colliders will automatically be put to sleep. |
tags | table | {} | A list of collision tags colliders can be assigned to. |
Returns
Name | Type | Description |
world | World | 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
lovr.physics