class_physicsbody2d.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the PhysicsBody2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_PhysicsBody2D:
  5. PhysicsBody2D
  6. =============
  7. **Inherits:** :ref:`CollisionObject2D<class_CollisionObject2D>` **<** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  8. **Inherited By:** :ref:`KinematicBody2D<class_KinematicBody2D>`, :ref:`RigidBody2D<class_RigidBody2D>`, :ref:`StaticBody2D<class_StaticBody2D>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base class for all objects affected by physics in 2D space.
  13. Properties
  14. ----------
  15. +-----------------------+-------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`collision_layer<class_PhysicsBody2D_collision_layer>` |
  17. +-----------------------+-------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`collision_mask<class_PhysicsBody2D_collision_mask>` |
  19. +-----------------------+-------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`layers<class_PhysicsBody2D_layers>` |
  21. +-----------------------+-------------------------------------------------------------+
  22. Methods
  23. -------
  24. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_collision_exception_with<class_PhysicsBody2D_add_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  26. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_Array>` | :ref:`get_collision_exceptions<class_PhysicsBody2D_get_collision_exceptions>` **(** **)** |
  28. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_PhysicsBody2D_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** const |
  30. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_PhysicsBody2D_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** const |
  32. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`remove_collision_exception_with<class_PhysicsBody2D_remove_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  34. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_collision_layer_bit<class_PhysicsBody2D_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  36. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_collision_mask_bit<class_PhysicsBody2D_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  38. +----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  39. Description
  40. -----------
  41. PhysicsBody2D is an abstract base class for implementing a physics body. All \*Body2D types inherit from it.
  42. Tutorials
  43. ---------
  44. - :doc:`../tutorials/physics/physics_introduction`
  45. Property Descriptions
  46. ---------------------
  47. .. _class_PhysicsBody2D_collision_layer:
  48. - :ref:`int<class_int>` **collision_layer**
  49. +----------+----------------------------+
  50. | *Setter* | set_collision_layer(value) |
  51. +----------+----------------------------+
  52. | *Getter* | get_collision_layer() |
  53. +----------+----------------------------+
  54. The physics layers this area is in.
  55. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
  56. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A.
  57. .. _class_PhysicsBody2D_collision_mask:
  58. - :ref:`int<class_int>` **collision_mask**
  59. +----------+---------------------------+
  60. | *Setter* | set_collision_mask(value) |
  61. +----------+---------------------------+
  62. | *Getter* | get_collision_mask() |
  63. +----------+---------------------------+
  64. The physics layers this area scans for collisions.
  65. .. _class_PhysicsBody2D_layers:
  66. - :ref:`int<class_int>` **layers**
  67. Both :ref:`collision_layer<class_PhysicsBody2D_collision_layer>` and :ref:`collision_mask<class_PhysicsBody2D_collision_mask>`. Returns :ref:`collision_layer<class_PhysicsBody2D_collision_layer>` when accessed. Updates :ref:`collision_layer<class_PhysicsBody2D_collision_layer>` and :ref:`collision_mask<class_PhysicsBody2D_collision_mask>` when modified.
  68. Method Descriptions
  69. -------------------
  70. .. _class_PhysicsBody2D_add_collision_exception_with:
  71. - void **add_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  72. Adds a body to the list of bodies that this body can't collide with.
  73. .. _class_PhysicsBody2D_get_collision_exceptions:
  74. - :ref:`Array<class_Array>` **get_collision_exceptions** **(** **)**
  75. Returns an array of nodes that were added as collision exceptions for this body.
  76. .. _class_PhysicsBody2D_get_collision_layer_bit:
  77. - :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** const
  78. Returns an individual bit on the collision mask.
  79. .. _class_PhysicsBody2D_get_collision_mask_bit:
  80. - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** const
  81. Returns an individual bit on the collision mask.
  82. .. _class_PhysicsBody2D_remove_collision_exception_with:
  83. - void **remove_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  84. Removes a body from the list of bodies that this body can't collide with.
  85. .. _class_PhysicsBody2D_set_collision_layer_bit:
  86. - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  87. Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
  88. .. _class_PhysicsBody2D_set_collision_mask_bit:
  89. - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  90. Sets individual bits on the collision mask. Use this if you only need to change one layer's value.