lovr.physics

Edit

The lovr.physics module simulates 3D rigid body physics.

Worlds

A physics World holds all of the colliders and joints in the simulation. It must be updated every frame using World:update, during which it will move all the colliders and resolve collisions between them.

lovr.physics.newWorldCreate a new World.

Colliders

Colliders are objects that represent a single rigid body in the physics simulation. They can have forces applied to them and collide with other colliders.

World:getCollidersGet a table of all Colliders in the World.
World:newBoxColliderAdd a Collider with a BoxShape to the World.
World:newCapsuleColliderAdd a Collider with a CapsuleShape to the World.
World:newColliderAdd a Collider to the World.
World:newCylinderColliderAdd a Collider with a CylinderShape to the World.
World:newMeshColliderAdd a Collider with a MeshShape to the World.
World:newSphereColliderAdd a Collider with a SphereShape to the World.
World:newTerrainColliderAdd a Collider with a TerrainShape to the World.

Shapes

Shapes are 3D physics shapes that can be attached to colliders. Shapes define, well, the shape of a Collider and how it collides with other objects. Without any Shapes, a collider wouldn't collide with anything.

Normally, you don't need to create Shapes yourself, as there are convenience functions on the World that will create colliders with shapes already attached. However, you can attach multiple Shapes to a collider to create more complicated objects, and sometimes it can be useful to access the individual Shapes on a collider.

lovr.physics.newBoxShapeCreate a new BoxShape.
lovr.physics.newCapsuleShapeCreate a new CapsuleShape.
lovr.physics.newCylinderShapeCreate a new CylinderShape.
lovr.physics.newMeshShapeCreate a new MeshShape.
lovr.physics.newSphereShapeCreate a new SphereShape.
lovr.physics.newTerrainShapeCreate a new TerrainShape.

Joints

Joints are objects that constrain the movement of colliders in various ways. Joints are attached to two colliders when they're created and usually have a concept of an "anchor", which is where the Joint is attached to relative to the colliders. Joints can be used to create all sorts of neat things like doors, drawers, buttons, levers, or pendulums.

lovr.physics.newBallJointCreate a new BallJoint.
lovr.physics.newDistanceJointCreate a new DistanceJoint.
lovr.physics.newHingeJointCreate a new HingeJoint.
lovr.physics.newSliderJointCreate a new SliderJoint.