World

Edit

A 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.newWorldCreate a new World.

Basics

World:updateAdvance the physics simulation.
World:interpolateInterpolate collider poses.
World:getGravityGet the gravity of the World.
World:setGravitySet the gravity of the World.
World:getCallbacksGet the World's collision callbacks.
World:setCallbacksSet the World's collision callbacks.
World:destroyDestroy the World!! Muahaha!
World:isDestroyedCheck 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:

World:raycastFind colliders that intersect a line.
World:shapecastMove a shape through the world and return any colliders it touches.
World:overlapShapeFind colliders that overlap a shape.
World:queryBoxFind colliders that intersect an axis-aligned box.
World:querySphereFind 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:getTagsGet the World's list of collision tags.
World:disableCollisionBetweenDisable collision between two tags.
World:enableCollisionBetweenEnable collision between two tags.
World:isCollisionEnabledBetweenCheck if two tags can collide.

Colliders

World:newColliderAdd a Collider to the World.
World:newBoxColliderAdd a Collider with a BoxShape to the World.
World:newSphereColliderAdd a Collider with a SphereShape to the World.
World:newCapsuleColliderAdd a Collider with a CapsuleShape to the World.
World:newCylinderColliderAdd a Collider with a CylinderShape to the World.
World:newConvexColliderAdd a Collider with a ConvexShape to the World.
World:newMeshColliderAdd a Collider with a MeshShape to the World.
World:newTerrainColliderAdd a Collider with a TerrainShape to the World.
World:getColliderCountGet the number of colliders in the world.
World:getCollidersGet a list of colliders in the World.

Joints

World:getJointCountGet the number of joints in the world.
World:getJointsGet a list of joints in the World.

See also