class_collisionshape2d.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. **IMPORTANT**: this is an Editor-only helper to create shapes, use :ref:`CollisionObject2D.shape_owner_get_shape<class_CollisionObject2D_method_shape_owner_get_shape>` to get the actual 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:`bool<class_bool>` | :ref:`disabled<class_CollisionShape2D_property_disabled>` | ``false`` |
  30. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`one_way_collision<class_CollisionShape2D_property_one_way_collision>` | ``false`` |
  32. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  33. | :ref:`float<class_float>` | :ref:`one_way_collision_margin<class_CollisionShape2D_property_one_way_collision_margin>` | ``1.0`` |
  34. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  35. | :ref:`Shape2D<class_Shape2D>` | :ref:`shape<class_CollisionShape2D_property_shape>` | |
  36. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  37. .. rst-class:: classref-section-separator
  38. ----
  39. .. rst-class:: classref-descriptions-group
  40. Property Descriptions
  41. ---------------------
  42. .. _class_CollisionShape2D_property_disabled:
  43. .. rst-class:: classref-property
  44. :ref:`bool<class_bool>` **disabled** = ``false``
  45. .. rst-class:: classref-property-setget
  46. - void **set_disabled** **(** :ref:`bool<class_bool>` value **)**
  47. - :ref:`bool<class_bool>` **is_disabled** **(** **)**
  48. 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>`.
  49. .. rst-class:: classref-item-separator
  50. ----
  51. .. _class_CollisionShape2D_property_one_way_collision:
  52. .. rst-class:: classref-property
  53. :ref:`bool<class_bool>` **one_way_collision** = ``false``
  54. .. rst-class:: classref-property-setget
  55. - void **set_one_way_collision** **(** :ref:`bool<class_bool>` value **)**
  56. - :ref:`bool<class_bool>` **is_one_way_collision_enabled** **(** **)**
  57. Sets whether this collision shape should only detect collision on one side (top or bottom).
  58. \ **Note:** This property has no effect if this **CollisionShape2D** is a child of an :ref:`Area2D<class_Area2D>` node.
  59. .. rst-class:: classref-item-separator
  60. ----
  61. .. _class_CollisionShape2D_property_one_way_collision_margin:
  62. .. rst-class:: classref-property
  63. :ref:`float<class_float>` **one_way_collision_margin** = ``1.0``
  64. .. rst-class:: classref-property-setget
  65. - void **set_one_way_collision_margin** **(** :ref:`float<class_float>` value **)**
  66. - :ref:`float<class_float>` **get_one_way_collision_margin** **(** **)**
  67. 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.
  68. .. rst-class:: classref-item-separator
  69. ----
  70. .. _class_CollisionShape2D_property_shape:
  71. .. rst-class:: classref-property
  72. :ref:`Shape2D<class_Shape2D>` **shape**
  73. .. rst-class:: classref-property-setget
  74. - void **set_shape** **(** :ref:`Shape2D<class_Shape2D>` value **)**
  75. - :ref:`Shape2D<class_Shape2D>` **get_shape** **(** **)**
  76. The actual shape owned by this collision shape.
  77. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  78. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  79. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  80. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`