collide.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. return {
  2. tag = 'worldCollision',
  3. summary = 'Attempt to collide two shapes.',
  4. description = [[
  5. Attempt to collide two shapes. Internally this uses joints and forces to ensure the colliders
  6. attached to the shapes do not pass through each other. Collisions can be customized using
  7. friction and restitution (bounciness) parameters, and default to using a mix of the colliders'
  8. friction and restitution parameters. Usually this is called automatically by `World:update`.
  9. ]],
  10. arguments = {
  11. {
  12. name = 'shapeA',
  13. type = 'Shape',
  14. description = 'The first shape.'
  15. },
  16. {
  17. name = 'shapeB',
  18. type = 'Shape',
  19. description = 'The second shape.'
  20. },
  21. {
  22. name = 'friction',
  23. type = 'number',
  24. default = 'nil',
  25. description = 'The friction parameter for the collision.'
  26. },
  27. {
  28. name = 'restitution',
  29. type = 'number',
  30. default = 'nil',
  31. description = 'The restitution (bounciness) parameter for the collision.'
  32. },
  33. },
  34. returns = {
  35. {
  36. name = 'collided',
  37. type = 'boolean',
  38. description = 'Whether the shapes collided.'
  39. }
  40. },
  41. notes = [[
  42. For friction, numbers in the range of 0-1 are common, but larger numbers can also be used.
  43. For restitution, numbers in the range 0-1 should be used.
  44. This function respects collision tags, so using `World:disableCollisionBetween` and
  45. `World:enableCollisionBetween` will change the behavior of this function.
  46. ]],
  47. related = {
  48. 'World:computeOverlaps',
  49. 'World:overlaps',
  50. 'World:disableCollisionBetween',
  51. 'World:enableCollisionBetween',
  52. 'World:isCollisionEnabledBetween'
  53. }
  54. }