World:collide
EditAttempt 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
Name | Type | Default | Description |
shapeA | Shape | The first shape. | |
shapeB | Shape | The second shape. | |
friction | number | nil | The friction parameter for the collision. |
restitution | number | nil | The restitution (bounciness) parameter for the collision. |
Returns
Name | Type | Description |
collided | boolean | 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
World:computeOverlaps
World:overlaps
World:disableCollisionBetween
World:enableCollisionBetween
World:isCollisionEnabledBetween
World