World:collide

Edit

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
shapeAShape The first shape.
shapeBShape The second shape.
frictionnumbernil The friction parameter for the collision.
restitutionnumbernil The restitution (bounciness) parameter for the collision.

Returns

NameTypeDescription
collidedboolean Whether 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