World:collide

Attempt to collide two shapes. Internally this uses joints and forces to ensure the colliders attached to the shapes do not pass through each other. Collisions can be customized using friction and restitution (bounciness) parameters, and default to using a mix of the colliders' friction and restitution parameters. Usually this is called automatically by World:update.

collided = World:collide(shapeA, shapeB, friction, restitution)

Arguments

NameTypeDefaultDescription
shapeAShapeThe first shape.
shapeBShapeThe second shape.
frictionnumbernilThe friction parameter for the collision.
restitutionnumbernilThe restitution (bounciness) parameter for the collision.

Returns

NameTypeDescription
collidedbooleanWhether the shapes collided.

Notes

For friction, numbers in the range of 0-1 are common, but larger numbers can also be used.

For restitution, numbers in the range 0-1 should be used.

This function respects collision tags, so using World:disableCollisionBetween and World:enableCollisionBetween will change the behavior of this function.

See also