World:newCollider
EditAdds a new Collider to the World.
Arguments
Name | Type | Default | Description |
x | number | 0 | The x position of the Collider. |
y | number | 0 | The y position of the Collider. |
z | number | 0 | The z position of the Collider. |
Returns
Name | Type | Description |
collider | Collider | The new Collider. |
Arguments
Name | Type | Description |
position | Vec3 | The position of the Collider. |
Returns
Name | Type | Description |
collider | Collider | The new Collider. |
Notes
This function creates a collider without any shapes attached to it, which means it won't collide with anything. To add a shape to the collider, use Collider:addShape
, or use one of the following functions to create the collider:
World:newBoxCollider
World:newCapsuleCollider
World:newCylinderCollider
World:newSphereCollider
Example
Create a new world, add a collider to it, and update it, printing out the collider's 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
World:newBoxCollider
World:newCapsuleCollider
World:newCylinderCollider
World:newMeshCollider
World:newSphereCollider
Collider
Shape
World