collide.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. return {
  2. tag = 'worldCollision',
  3. summary = 'Attempt to collide two shapes.',
  4. description = [[
  5. Attempt to collide two shapes. Internally this sets up constraint forces to move the shapes'
  6. colliders apart if they are touching. The colliders won't actually move until `World:update` is
  7. called again to advance the physics simulation.
  8. Collision responses can be customized using friction and restitution (bounciness) parameters,
  9. and default to using a mix between the parameters of the two colliders.
  10. Usually this is called internally by `World:update`, or in a custom collision resolver passed to
  11. `World:update`.
  12. If you want to detect if objects are touching without colliding them, use `World:getContacts`
  13. or make one or both of the shapes sensors using `Shape:setSensor`.
  14. ]],
  15. arguments = {
  16. shapeA = {
  17. type = 'Shape',
  18. description = 'The first shape.'
  19. },
  20. shapeB = {
  21. type = 'Shape',
  22. description = 'The second shape.'
  23. },
  24. friction = {
  25. type = 'number',
  26. default = 'nil',
  27. description = 'The friction parameter for the collision.'
  28. },
  29. restitution = {
  30. type = 'number',
  31. default = 'nil',
  32. description = 'The restitution (bounciness) parameter for the collision.'
  33. },
  34. },
  35. returns = {
  36. collided = {
  37. type = 'boolean',
  38. description = 'Whether the shapes collided.'
  39. }
  40. },
  41. variants = {
  42. {
  43. arguments = { 'shapeA', 'shapeB', 'friction', 'restitution' },
  44. returns = { 'collided' }
  45. }
  46. },
  47. notes = [[
  48. For friction, numbers in the range of 0-1 are common, but larger numbers can also be used.
  49. For restitution, numbers in the range 0-1 should be used.
  50. This function respects collision tags, so using `World:disableCollisionBetween` and
  51. `World:enableCollisionBetween` will change the behavior of this function.
  52. ]],
  53. related = {
  54. 'World:computeOverlaps',
  55. 'World:overlaps',
  56. 'World:disableCollisionBetween',
  57. 'World:enableCollisionBetween',
  58. 'World:isCollisionEnabledBetween',
  59. 'Collider:setFriction',
  60. 'Collider:setRestitution'
  61. }
  62. }