World
EditA World is an object that holds all of the colliders and joints in a physics simulation.
Be sure to call World:update on the World every frame to advance the simulation.
Constructor
| lovr.physics.newWorld | Create a new World. |
Basics
| World:update | Advance the physics simulation. |
| World:interpolate | Interpolate collider poses. |
| World:getGravity | Get the gravity of the World. |
| World:setGravity | Set the gravity of the World. |
| World:getCallbacks | Get the World's collision callbacks. |
| World:setCallbacks | Set the World's collision callbacks. |
| World:destroy | Destroy the World!! Muahaha! |
| World:isDestroyed | Check if the World has been destroyed. |
Queries
Queries answer some question about the World, like "do any colliders intersect this line?" or "are there any colliders inside this sphere?". There are 3 types of queries:
- "cast" tests sweep a shape along a line and figure out which colliders are in its path.
- "overlap" tests place a shape at a position and figure out which colliders it touches.
- "query" tests are similar to overlap tests, but they are fast and inexact. They only check the bounding box of a collider, and only support testing against simple shapes.
| World:raycast | Find colliders that intersect a line. |
| World:shapecast | Move a shape through the world and return any colliders it touches. |
| World:overlapShape | Find colliders that overlap a shape. |
| World:queryBox | Find colliders that intersect an axis-aligned box. |
| World:querySphere | Find colliders that intersect a sphere. |
Collision Tags
Collision tags are used to ignore collision between certain pairs of colliders. The list of available tags is defined when creating the world, and colliders can be given a tag using Collider:setTag.
| World:getTags | Get the World's list of collision tags. |
| World:disableCollisionBetween | Disable collision between two tags. |
| World:enableCollisionBetween | Enable collision between two tags. |
| World:isCollisionEnabledBetween | Check if two tags can collide. |
Colliders
| World:newCollider | Add a Collider to the World. |
| World:newBoxCollider | Add a Collider with a BoxShape to the World. |
| World:newSphereCollider | Add a Collider with a SphereShape to the World. |
| World:newCapsuleCollider | Add a Collider with a CapsuleShape to the World. |
| World:newCylinderCollider | Add a Collider with a CylinderShape to the World. |
| World:newConvexCollider | Add a Collider with a ConvexShape to the World. |
| World:newMeshCollider | Add a Collider with a MeshShape to the World. |
| World:newTerrainCollider | Add a Collider with a TerrainShape to the World. |
| World:getColliderCount | Get the number of colliders in the world. |
| World:getColliders | Get a list of colliders in the World. |
Joints
| World:getJointCount | Get the number of joints in the world. |
| World:getJoints | Get a list of joints in the World. |