World
EditA World is an object that holds the colliders, joints, and shapes in a physics simulation.
Constructor
lovr.physics.newWorld | Create a new World. |
Basics
World:destroy | Destroy the World!! Muahaha! |
World:raycast | Cast a ray through the World. |
World:update | Update the World. |
Colliders
The following functions add Colliders to the World. World:newCollider
adds an "empty" Collider without any Shapes attached, whereas the other functions are shortcut functions to add Colliders with Shapes already attached to them.
World:getColliders | Get a table of all Colliders in the World. |
World:newBoxCollider | Add a Collider with a BoxShape to the World. |
World:newCapsuleCollider | Add a Collider with a CapsuleShape to the World. |
World:newCollider | Add a Collider to the World. |
World:newCylinderCollider | Add a Collider with a CylinderShape to the World. |
World:newMeshCollider | Add a Collider with a MeshShape to the World. |
World:newSphereCollider | Add a Collider with a SphereShape to the World. |
Properties
The following functions are global properties of the simulation that apply to all new Colliders.
World:getAngularDamping | Get the angular damping of the World. |
World:getGravity | Get the gravity of the World. |
World:getLinearDamping | Get the linear damping of the World. |
World:getResponseTime | Get the response time of the World. |
World:getStepCount | Get the step count of the World. |
World:getTightness | Get the tightness of joints in the World. |
World:isSleepingAllowed | Check if colliders can go to sleep. |
World:setAngularDamping | Set the angular damping of the World. |
World:setGravity | Set the gravity of the World. |
World:setLinearDamping | Set the linear damping of the World. |
World:setResponseTime | Set the response time of the World. |
World:setSleepingAllowed | Set whether colliders can go to sleep. |
World:setStepCount | Set the step count of the World. |
World:setTightness | Set the tightness of joints in the World. |
Collision
When the World is created using lovr.physics.newWorld
, it is possible to specify a list of collision tags for the World. Colliders can then be assigned a tag. You can enable and disable collision between pairs of tags. There are also some helper functions to quickly identify pairs of colliders that are near each other and test whether or not they are colliding. These are used internally by default by World:update
, but you can override this behavior and use the functions directly for custom collision behavior.
World:collide | Attempt to collide two shapes. |
World:computeOverlaps | Compute pairs of shapes that are close to each other. |
World:disableCollisionBetween | Disable collision between two tags. |
World:enableCollisionBetween | Enable collision between two tags. |
World:getContacts | Get a list of points where a pair of shapes touch. |
World:isCollisionEnabledBetween | Check if two tags can collide. |
World:overlaps | Iterate over pairs of nearby shapes. |
Notes
Be sure to update the World in lovr.update
using World:update
, otherwise everything will stand still.