class_kinematiccollision2d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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/KinematicCollision2D.xml.
  6. .. _class_KinematicCollision2D:
  7. KinematicCollision2D
  8. ====================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Holds collision data from the movement of a :ref:`PhysicsBody2D<class_PhysicsBody2D>`.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Holds collision data from the movement of a :ref:`PhysicsBody2D<class_PhysicsBody2D>`, usually from :ref:`PhysicsBody2D.move_and_collide<class_PhysicsBody2D_method_move_and_collide>`. When a :ref:`PhysicsBody2D<class_PhysicsBody2D>` is moved, it stops if it detects a collision with another body. If a collision is detected, a **KinematicCollision2D** object is returned.
  15. The collision data includes the colliding object, the remaining motion, and the collision position. This data can be used to determine a custom response to the collision.
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`get_angle<class_KinematicCollision2D_method_get_angle>`\ (\ up_direction\: :ref:`Vector2<class_Vector2>` = Vector2(0, -1)\ ) |const| |
  23. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Object<class_Object>` | :ref:`get_collider<class_KinematicCollision2D_method_get_collider>`\ (\ ) |const| |
  25. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_collider_id<class_KinematicCollision2D_method_get_collider_id>`\ (\ ) |const| |
  27. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`RID<class_RID>` | :ref:`get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>`\ (\ ) |const| |
  29. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Object<class_Object>` | :ref:`get_collider_shape<class_KinematicCollision2D_method_get_collider_shape>`\ (\ ) |const| |
  31. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_collider_shape_index<class_KinematicCollision2D_method_get_collider_shape_index>`\ (\ ) |const| |
  33. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Vector2<class_Vector2>` | :ref:`get_collider_velocity<class_KinematicCollision2D_method_get_collider_velocity>`\ (\ ) |const| |
  35. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_depth<class_KinematicCollision2D_method_get_depth>`\ (\ ) |const| |
  37. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Object<class_Object>` | :ref:`get_local_shape<class_KinematicCollision2D_method_get_local_shape>`\ (\ ) |const| |
  39. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Vector2<class_Vector2>` | :ref:`get_normal<class_KinematicCollision2D_method_get_normal>`\ (\ ) |const| |
  41. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Vector2<class_Vector2>` | :ref:`get_position<class_KinematicCollision2D_method_get_position>`\ (\ ) |const| |
  43. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector2<class_Vector2>` | :ref:`get_remainder<class_KinematicCollision2D_method_get_remainder>`\ (\ ) |const| |
  45. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector2<class_Vector2>` | :ref:`get_travel<class_KinematicCollision2D_method_get_travel>`\ (\ ) |const| |
  47. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  48. .. rst-class:: classref-section-separator
  49. ----
  50. .. rst-class:: classref-descriptions-group
  51. Method Descriptions
  52. -------------------
  53. .. _class_KinematicCollision2D_method_get_angle:
  54. .. rst-class:: classref-method
  55. :ref:`float<class_float>` **get_angle**\ (\ up_direction\: :ref:`Vector2<class_Vector2>` = Vector2(0, -1)\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_angle>`
  56. Returns the collision angle according to ``up_direction``, which is :ref:`Vector2.UP<class_Vector2_constant_UP>` by default. This value is always positive.
  57. .. rst-class:: classref-item-separator
  58. ----
  59. .. _class_KinematicCollision2D_method_get_collider:
  60. .. rst-class:: classref-method
  61. :ref:`Object<class_Object>` **get_collider**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider>`
  62. Returns the colliding body's attached :ref:`Object<class_Object>`.
  63. .. rst-class:: classref-item-separator
  64. ----
  65. .. _class_KinematicCollision2D_method_get_collider_id:
  66. .. rst-class:: classref-method
  67. :ref:`int<class_int>` **get_collider_id**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider_id>`
  68. Returns the unique instance ID of the colliding body's attached :ref:`Object<class_Object>`. See :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`.
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _class_KinematicCollision2D_method_get_collider_rid:
  72. .. rst-class:: classref-method
  73. :ref:`RID<class_RID>` **get_collider_rid**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider_rid>`
  74. Returns the colliding body's :ref:`RID<class_RID>` used by the :ref:`PhysicsServer2D<class_PhysicsServer2D>`.
  75. .. rst-class:: classref-item-separator
  76. ----
  77. .. _class_KinematicCollision2D_method_get_collider_shape:
  78. .. rst-class:: classref-method
  79. :ref:`Object<class_Object>` **get_collider_shape**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider_shape>`
  80. Returns the colliding body's shape.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_KinematicCollision2D_method_get_collider_shape_index:
  84. .. rst-class:: classref-method
  85. :ref:`int<class_int>` **get_collider_shape_index**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider_shape_index>`
  86. Returns the colliding body's shape index. See :ref:`CollisionObject2D<class_CollisionObject2D>`.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_KinematicCollision2D_method_get_collider_velocity:
  90. .. rst-class:: classref-method
  91. :ref:`Vector2<class_Vector2>` **get_collider_velocity**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_collider_velocity>`
  92. Returns the colliding body's velocity.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_KinematicCollision2D_method_get_depth:
  96. .. rst-class:: classref-method
  97. :ref:`float<class_float>` **get_depth**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_depth>`
  98. Returns the colliding body's length of overlap along the collision normal.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_KinematicCollision2D_method_get_local_shape:
  102. .. rst-class:: classref-method
  103. :ref:`Object<class_Object>` **get_local_shape**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_local_shape>`
  104. Returns the moving object's colliding shape.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_KinematicCollision2D_method_get_normal:
  108. .. rst-class:: classref-method
  109. :ref:`Vector2<class_Vector2>` **get_normal**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_normal>`
  110. Returns the colliding body's shape's normal at the point of collision.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_KinematicCollision2D_method_get_position:
  114. .. rst-class:: classref-method
  115. :ref:`Vector2<class_Vector2>` **get_position**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_position>`
  116. Returns the point of collision in global coordinates.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_KinematicCollision2D_method_get_remainder:
  120. .. rst-class:: classref-method
  121. :ref:`Vector2<class_Vector2>` **get_remainder**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_remainder>`
  122. Returns the moving object's remaining movement vector.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_KinematicCollision2D_method_get_travel:
  126. .. rst-class:: classref-method
  127. :ref:`Vector2<class_Vector2>` **get_travel**\ (\ ) |const| :ref:`🔗<class_KinematicCollision2D_method_get_travel>`
  128. Returns the moving object's travel before collision.
  129. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  130. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  131. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  132. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  133. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  134. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  135. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  136. .. |void| replace:: :abbr:`void (No return value.)`