class_kinematiccollision2d.rst 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 KinematicCollision2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_KinematicCollision2D:
  6. KinematicCollision2D
  7. ====================
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Collision data for :ref:`KinematicBody2D<class_KinematicBody2D>` collisions.
  10. Description
  11. -----------
  12. Contains collision data for :ref:`KinematicBody2D<class_KinematicBody2D>` collisions. When a :ref:`KinematicBody2D<class_KinematicBody2D>` is moved using :ref:`KinematicBody2D.move_and_collide<class_KinematicBody2D_method_move_and_collide>`, it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision2D object is returned.
  13. This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response.
  14. Properties
  15. ----------
  16. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  17. | :ref:`Object<class_Object>` | :ref:`collider<class_KinematicCollision2D_property_collider>` | |
  18. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  19. | :ref:`int<class_int>` | :ref:`collider_id<class_KinematicCollision2D_property_collider_id>` | ``0`` |
  20. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  21. | :ref:`Variant<class_Variant>` | :ref:`collider_metadata<class_KinematicCollision2D_property_collider_metadata>` | |
  22. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  23. | :ref:`RID<class_RID>` | :ref:`collider_rid<class_KinematicCollision2D_property_collider_rid>` | |
  24. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  25. | :ref:`Object<class_Object>` | :ref:`collider_shape<class_KinematicCollision2D_property_collider_shape>` | |
  26. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  27. | :ref:`int<class_int>` | :ref:`collider_shape_index<class_KinematicCollision2D_property_collider_shape_index>` | ``0`` |
  28. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  29. | :ref:`Vector2<class_Vector2>` | :ref:`collider_velocity<class_KinematicCollision2D_property_collider_velocity>` | ``Vector2( 0, 0 )`` |
  30. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  31. | :ref:`Object<class_Object>` | :ref:`local_shape<class_KinematicCollision2D_property_local_shape>` | |
  32. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`normal<class_KinematicCollision2D_property_normal>` | ``Vector2( 0, 0 )`` |
  34. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`position<class_KinematicCollision2D_property_position>` | ``Vector2( 0, 0 )`` |
  36. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  37. | :ref:`Vector2<class_Vector2>` | :ref:`remainder<class_KinematicCollision2D_property_remainder>` | ``Vector2( 0, 0 )`` |
  38. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  39. | :ref:`Vector2<class_Vector2>` | :ref:`travel<class_KinematicCollision2D_property_travel>` | ``Vector2( 0, 0 )`` |
  40. +-------------------------------+---------------------------------------------------------------------------------------+---------------------+
  41. Methods
  42. -------
  43. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_angle<class_KinematicCollision2D_method_get_angle>` **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2( 0, -1 ) **)** |const| |
  45. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  46. Property Descriptions
  47. ---------------------
  48. .. _class_KinematicCollision2D_property_collider:
  49. - :ref:`Object<class_Object>` **collider**
  50. +----------+----------------+
  51. | *Getter* | get_collider() |
  52. +----------+----------------+
  53. The colliding body.
  54. ----
  55. .. _class_KinematicCollision2D_property_collider_id:
  56. - :ref:`int<class_int>` **collider_id**
  57. +-----------+-------------------+
  58. | *Default* | ``0`` |
  59. +-----------+-------------------+
  60. | *Getter* | get_collider_id() |
  61. +-----------+-------------------+
  62. The colliding body's unique instance ID. See :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`.
  63. ----
  64. .. _class_KinematicCollision2D_property_collider_metadata:
  65. - :ref:`Variant<class_Variant>` **collider_metadata**
  66. +----------+-------------------------+
  67. | *Getter* | get_collider_metadata() |
  68. +----------+-------------------------+
  69. The colliding body's metadata. See :ref:`Object<class_Object>`.
  70. ----
  71. .. _class_KinematicCollision2D_property_collider_rid:
  72. - :ref:`RID<class_RID>` **collider_rid**
  73. +----------+--------------------+
  74. | *Getter* | get_collider_rid() |
  75. +----------+--------------------+
  76. The colliding body's :ref:`RID<class_RID>` used by the :ref:`Physics2DServer<class_Physics2DServer>`.
  77. ----
  78. .. _class_KinematicCollision2D_property_collider_shape:
  79. - :ref:`Object<class_Object>` **collider_shape**
  80. +----------+----------------------+
  81. | *Getter* | get_collider_shape() |
  82. +----------+----------------------+
  83. The colliding body's shape.
  84. ----
  85. .. _class_KinematicCollision2D_property_collider_shape_index:
  86. - :ref:`int<class_int>` **collider_shape_index**
  87. +-----------+----------------------------+
  88. | *Default* | ``0`` |
  89. +-----------+----------------------------+
  90. | *Getter* | get_collider_shape_index() |
  91. +-----------+----------------------------+
  92. The colliding shape's index. See :ref:`CollisionObject2D<class_CollisionObject2D>`.
  93. ----
  94. .. _class_KinematicCollision2D_property_collider_velocity:
  95. - :ref:`Vector2<class_Vector2>` **collider_velocity**
  96. +-----------+-------------------------+
  97. | *Default* | ``Vector2( 0, 0 )`` |
  98. +-----------+-------------------------+
  99. | *Getter* | get_collider_velocity() |
  100. +-----------+-------------------------+
  101. The colliding object's velocity.
  102. ----
  103. .. _class_KinematicCollision2D_property_local_shape:
  104. - :ref:`Object<class_Object>` **local_shape**
  105. +----------+-------------------+
  106. | *Getter* | get_local_shape() |
  107. +----------+-------------------+
  108. The moving object's colliding shape.
  109. ----
  110. .. _class_KinematicCollision2D_property_normal:
  111. - :ref:`Vector2<class_Vector2>` **normal**
  112. +-----------+---------------------+
  113. | *Default* | ``Vector2( 0, 0 )`` |
  114. +-----------+---------------------+
  115. | *Getter* | get_normal() |
  116. +-----------+---------------------+
  117. The colliding body's shape's normal at the point of collision.
  118. ----
  119. .. _class_KinematicCollision2D_property_position:
  120. - :ref:`Vector2<class_Vector2>` **position**
  121. +-----------+---------------------+
  122. | *Default* | ``Vector2( 0, 0 )`` |
  123. +-----------+---------------------+
  124. | *Getter* | get_position() |
  125. +-----------+---------------------+
  126. The point of collision, in global coordinates.
  127. ----
  128. .. _class_KinematicCollision2D_property_remainder:
  129. - :ref:`Vector2<class_Vector2>` **remainder**
  130. +-----------+---------------------+
  131. | *Default* | ``Vector2( 0, 0 )`` |
  132. +-----------+---------------------+
  133. | *Getter* | get_remainder() |
  134. +-----------+---------------------+
  135. The moving object's remaining movement vector.
  136. ----
  137. .. _class_KinematicCollision2D_property_travel:
  138. - :ref:`Vector2<class_Vector2>` **travel**
  139. +-----------+---------------------+
  140. | *Default* | ``Vector2( 0, 0 )`` |
  141. +-----------+---------------------+
  142. | *Getter* | get_travel() |
  143. +-----------+---------------------+
  144. The distance the moving object traveled before collision.
  145. Method Descriptions
  146. -------------------
  147. .. _class_KinematicCollision2D_method_get_angle:
  148. - :ref:`float<class_float>` **get_angle** **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2( 0, -1 ) **)** |const|
  149. The collision angle according to ``up_direction``, which is ``Vector2.UP`` by default. This value is always positive.
  150. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  151. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  152. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`