class_collisionshape2d.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the CollisionShape2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_CollisionShape2D:
  6. CollisionShape2D
  7. ================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Node that represents collision shape data in 2D space.
  10. Description
  11. -----------
  12. Editor facility for creating and editing collision shapes in 2D space. 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. **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.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/physics/physics_introduction`
  16. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  17. - `2D Pong Demo <https://godotengine.org/asset-library/asset/121>`__
  18. - `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
  19. Properties
  20. ----------
  21. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  22. | :ref:`bool<class_bool>` | :ref:`disabled<class_CollisionShape2D_property_disabled>` | ``false`` |
  23. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`one_way_collision<class_CollisionShape2D_property_one_way_collision>` | ``false`` |
  25. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`float<class_float>` | :ref:`one_way_collision_margin<class_CollisionShape2D_property_one_way_collision_margin>` | ``1.0`` |
  27. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`Shape2D<class_Shape2D>` | :ref:`shape<class_CollisionShape2D_property_shape>` | |
  29. +-------------------------------+-------------------------------------------------------------------------------------------+-----------+
  30. Property Descriptions
  31. ---------------------
  32. .. _class_CollisionShape2D_property_disabled:
  33. - :ref:`bool<class_bool>` **disabled**
  34. +-----------+---------------------+
  35. | *Default* | ``false`` |
  36. +-----------+---------------------+
  37. | *Setter* | set_disabled(value) |
  38. +-----------+---------------------+
  39. | *Getter* | is_disabled() |
  40. +-----------+---------------------+
  41. 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>`.
  42. ----
  43. .. _class_CollisionShape2D_property_one_way_collision:
  44. - :ref:`bool<class_bool>` **one_way_collision**
  45. +-----------+--------------------------------+
  46. | *Default* | ``false`` |
  47. +-----------+--------------------------------+
  48. | *Setter* | set_one_way_collision(value) |
  49. +-----------+--------------------------------+
  50. | *Getter* | is_one_way_collision_enabled() |
  51. +-----------+--------------------------------+
  52. Sets whether this collision shape should only detect collision on one side (top or bottom).
  53. ----
  54. .. _class_CollisionShape2D_property_one_way_collision_margin:
  55. - :ref:`float<class_float>` **one_way_collision_margin**
  56. +-----------+-------------------------------------+
  57. | *Default* | ``1.0`` |
  58. +-----------+-------------------------------------+
  59. | *Setter* | set_one_way_collision_margin(value) |
  60. +-----------+-------------------------------------+
  61. | *Getter* | get_one_way_collision_margin() |
  62. +-----------+-------------------------------------+
  63. 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.
  64. ----
  65. .. _class_CollisionShape2D_property_shape:
  66. - :ref:`Shape2D<class_Shape2D>` **shape**
  67. +----------+------------------+
  68. | *Setter* | set_shape(value) |
  69. +----------+------------------+
  70. | *Getter* | get_shape() |
  71. +----------+------------------+
  72. The actual shape owned by this collision shape.
  73. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  74. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  75. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`