class_collisionshape2d.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/CollisionShape2D.xml.
  6. .. _class_CollisionShape2D:
  7. CollisionShape2D
  8. ================
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Node that represents collision shape data in 2D space.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Editor facility for creating and editing collision shapes in 2D space. Set the :ref:`shape<class_CollisionShape2D_property_shape>` property to configure the shape.
  15. You can use this node to represent all sorts of collision shapes, for example, add this to an :ref:`Area2D<class_Area2D>` to give it a detection shape, or add it to a :ref:`PhysicsBody2D<class_PhysicsBody2D>` to create a solid object.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Physics introduction <../tutorials/physics/physics_introduction>`
  20. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  21. - `2D Pong Demo <https://godotengine.org/asset-library/asset/121>`__
  22. - `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  29. | :ref:`Color<class_Color>` | :ref:`debug_color<class_CollisionShape2D_property_debug_color>` | ``Color(0, 0, 0, 1)`` |
  30. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  31. | :ref:`bool<class_bool>` | :ref:`disabled<class_CollisionShape2D_property_disabled>` | ``false`` |
  32. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  33. | :ref:`bool<class_bool>` | :ref:`one_way_collision<class_CollisionShape2D_property_one_way_collision>` | ``false`` |
  34. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  35. | :ref:`float<class_float>` | :ref:`one_way_collision_margin<class_CollisionShape2D_property_one_way_collision_margin>` | ``1.0`` |
  36. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  37. | :ref:`Shape2D<class_Shape2D>` | :ref:`shape<class_CollisionShape2D_property_shape>` | |
  38. +-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
  39. .. rst-class:: classref-section-separator
  40. ----
  41. .. rst-class:: classref-descriptions-group
  42. Property Descriptions
  43. ---------------------
  44. .. _class_CollisionShape2D_property_debug_color:
  45. .. rst-class:: classref-property
  46. :ref:`Color<class_Color>` **debug_color** = ``Color(0, 0, 0, 1)``
  47. .. rst-class:: classref-property-setget
  48. - void **set_debug_color** **(** :ref:`Color<class_Color>` value **)**
  49. - :ref:`Color<class_Color>` **get_debug_color** **(** **)**
  50. The collision shape debug color.
  51. \ **Note:** The default value is :ref:`ProjectSettings.debug/shapes/collision/shape_color<class_ProjectSettings_property_debug/shapes/collision/shape_color>`. The ``Color(0, 0, 0, 1)`` value documented here is a placeholder, and not the actual default debug color.
  52. .. rst-class:: classref-item-separator
  53. ----
  54. .. _class_CollisionShape2D_property_disabled:
  55. .. rst-class:: classref-property
  56. :ref:`bool<class_bool>` **disabled** = ``false``
  57. .. rst-class:: classref-property-setget
  58. - void **set_disabled** **(** :ref:`bool<class_bool>` value **)**
  59. - :ref:`bool<class_bool>` **is_disabled** **(** **)**
  60. A disabled collision shape has no effect in the world. This property should be changed with :ref:`Object.set_deferred<class_Object_method_set_deferred>`.
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_CollisionShape2D_property_one_way_collision:
  64. .. rst-class:: classref-property
  65. :ref:`bool<class_bool>` **one_way_collision** = ``false``
  66. .. rst-class:: classref-property-setget
  67. - void **set_one_way_collision** **(** :ref:`bool<class_bool>` value **)**
  68. - :ref:`bool<class_bool>` **is_one_way_collision_enabled** **(** **)**
  69. Sets whether this collision shape should only detect collision on one side (top or bottom).
  70. \ **Note:** This property has no effect if this **CollisionShape2D** is a child of an :ref:`Area2D<class_Area2D>` node.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_CollisionShape2D_property_one_way_collision_margin:
  74. .. rst-class:: classref-property
  75. :ref:`float<class_float>` **one_way_collision_margin** = ``1.0``
  76. .. rst-class:: classref-property-setget
  77. - void **set_one_way_collision_margin** **(** :ref:`float<class_float>` value **)**
  78. - :ref:`float<class_float>` **get_one_way_collision_margin** **(** **)**
  79. The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the shape at a high velocity.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_CollisionShape2D_property_shape:
  83. .. rst-class:: classref-property
  84. :ref:`Shape2D<class_Shape2D>` **shape**
  85. .. rst-class:: classref-property-setget
  86. - void **set_shape** **(** :ref:`Shape2D<class_Shape2D>` value **)**
  87. - :ref:`Shape2D<class_Shape2D>` **get_shape** **(** **)**
  88. The actual shape owned by this collision shape.
  89. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  90. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  91. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  92. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  93. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  94. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`