class_collisionpolygon2d.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CollisionPolygon2D.xml.
  6. .. _class_CollisionPolygon2D:
  7. CollisionPolygon2D
  8. ==================
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Defines a 2D collision polygon.
  11. Description
  12. -----------
  13. Provides a concave or convex 2D collision polygon to a :ref:`CollisionObject2D<class_CollisionObject2D>` parent. Polygons can be drawn in the editor or specified by a list of vertices. See also :ref:`ConvexPolygonShape2D<class_ConvexPolygonShape2D>`.
  14. In the editor, a ``CollisionPolygon2D`` can be generated from a :ref:`Sprite2D<class_Sprite2D>`'s outline by selecting a :ref:`Sprite2D<class_Sprite2D>` node, going to the **Sprite2D** menu at the top of the 2D editor viewport then choosing **Create CollisionPolygon2D Sibling**.
  15. Properties
  16. ----------
  17. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  18. | :ref:`BuildMode<enum_CollisionPolygon2D_BuildMode>` | :ref:`build_mode<class_CollisionPolygon2D_property_build_mode>` | ``0`` |
  19. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`disabled<class_CollisionPolygon2D_property_disabled>` | ``false`` |
  21. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`one_way_collision<class_CollisionPolygon2D_property_one_way_collision>` | ``false`` |
  23. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  24. | :ref:`float<class_float>` | :ref:`one_way_collision_margin<class_CollisionPolygon2D_property_one_way_collision_margin>` | ``1.0`` |
  25. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  26. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`polygon<class_CollisionPolygon2D_property_polygon>` | ``PackedVector2Array()`` |
  27. +-----------------------------------------------------+---------------------------------------------------------------------------------------------+--------------------------+
  28. Enumerations
  29. ------------
  30. .. _enum_CollisionPolygon2D_BuildMode:
  31. .. _class_CollisionPolygon2D_constant_BUILD_SOLIDS:
  32. .. _class_CollisionPolygon2D_constant_BUILD_SEGMENTS:
  33. enum **BuildMode**:
  34. - **BUILD_SOLIDS** = **0** --- Collisions will include the polygon and its contained area.
  35. - **BUILD_SEGMENTS** = **1** --- Collisions will only include the polygon edges.
  36. Property Descriptions
  37. ---------------------
  38. .. _class_CollisionPolygon2D_property_build_mode:
  39. - :ref:`BuildMode<enum_CollisionPolygon2D_BuildMode>` **build_mode**
  40. +-----------+-----------------------+
  41. | *Default* | ``0`` |
  42. +-----------+-----------------------+
  43. | *Setter* | set_build_mode(value) |
  44. +-----------+-----------------------+
  45. | *Getter* | get_build_mode() |
  46. +-----------+-----------------------+
  47. Collision build mode. Use one of the :ref:`BuildMode<enum_CollisionPolygon2D_BuildMode>` constants.
  48. ----
  49. .. _class_CollisionPolygon2D_property_disabled:
  50. - :ref:`bool<class_bool>` **disabled**
  51. +-----------+---------------------+
  52. | *Default* | ``false`` |
  53. +-----------+---------------------+
  54. | *Setter* | set_disabled(value) |
  55. +-----------+---------------------+
  56. | *Getter* | is_disabled() |
  57. +-----------+---------------------+
  58. If ``true``, no collisions will be detected.
  59. ----
  60. .. _class_CollisionPolygon2D_property_one_way_collision:
  61. - :ref:`bool<class_bool>` **one_way_collision**
  62. +-----------+--------------------------------+
  63. | *Default* | ``false`` |
  64. +-----------+--------------------------------+
  65. | *Setter* | set_one_way_collision(value) |
  66. +-----------+--------------------------------+
  67. | *Getter* | is_one_way_collision_enabled() |
  68. +-----------+--------------------------------+
  69. If ``true``, only edges that face up, relative to ``CollisionPolygon2D``'s rotation, will collide with other objects.
  70. \ **Note:** This property has no effect if this ``CollisionPolygon2D`` is a child of an :ref:`Area2D<class_Area2D>` node.
  71. ----
  72. .. _class_CollisionPolygon2D_property_one_way_collision_margin:
  73. - :ref:`float<class_float>` **one_way_collision_margin**
  74. +-----------+-------------------------------------+
  75. | *Default* | ``1.0`` |
  76. +-----------+-------------------------------------+
  77. | *Setter* | set_one_way_collision_margin(value) |
  78. +-----------+-------------------------------------+
  79. | *Getter* | get_one_way_collision_margin() |
  80. +-----------+-------------------------------------+
  81. The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the polygon at a high velocity.
  82. ----
  83. .. _class_CollisionPolygon2D_property_polygon:
  84. - :ref:`PackedVector2Array<class_PackedVector2Array>` **polygon**
  85. +-----------+--------------------------+
  86. | *Default* | ``PackedVector2Array()`` |
  87. +-----------+--------------------------+
  88. | *Setter* | set_polygon(value) |
  89. +-----------+--------------------------+
  90. | *Getter* | get_polygon() |
  91. +-----------+--------------------------+
  92. The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the :ref:`PackedVector2Array<class_PackedVector2Array>`, not a reference.
  93. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  94. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  95. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  96. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  97. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  98. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`