class_kinematiccollision2d.rst 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. Collision data for :ref:`PhysicsBody2D.move_and_collide<class_PhysicsBody2D_method_move_and_collide>` collisions.
  10. Description
  11. -----------
  12. Contains collision data for :ref:`PhysicsBody2D.move_and_collide<class_PhysicsBody2D_method_move_and_collide>` collisions. When a :ref:`PhysicsBody2D<class_PhysicsBody2D>` is moved using :ref:`PhysicsBody2D.move_and_collide<class_PhysicsBody2D_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. Methods
  15. -------
  16. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`float<class_float>` | :ref:`get_angle<class_KinematicCollision2D_method_get_angle>` **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2(0, -1) **)** |const| |
  18. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Object<class_Object>` | :ref:`get_collider<class_KinematicCollision2D_method_get_collider>` **(** **)** |const| |
  20. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_collider_id<class_KinematicCollision2D_method_get_collider_id>` **(** **)** |const| |
  22. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`RID<class_RID>` | :ref:`get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>` **(** **)** |const| |
  24. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Object<class_Object>` | :ref:`get_collider_shape<class_KinematicCollision2D_method_get_collider_shape>` **(** **)** |const| |
  26. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_collider_shape_index<class_KinematicCollision2D_method_get_collider_shape_index>` **(** **)** |const| |
  28. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2<class_Vector2>` | :ref:`get_collider_velocity<class_KinematicCollision2D_method_get_collider_velocity>` **(** **)** |const| |
  30. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Object<class_Object>` | :ref:`get_local_shape<class_KinematicCollision2D_method_get_local_shape>` **(** **)** |const| |
  32. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`get_normal<class_KinematicCollision2D_method_get_normal>` **(** **)** |const| |
  34. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`get_position<class_KinematicCollision2D_method_get_position>` **(** **)** |const| |
  36. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector2<class_Vector2>` | :ref:`get_remainder<class_KinematicCollision2D_method_get_remainder>` **(** **)** |const| |
  38. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector2<class_Vector2>` | :ref:`get_travel<class_KinematicCollision2D_method_get_travel>` **(** **)** |const| |
  40. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  41. Method Descriptions
  42. -------------------
  43. .. _class_KinematicCollision2D_method_get_angle:
  44. - :ref:`float<class_float>` **get_angle** **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2(0, -1) **)** |const|
  45. Returns the collision angle according to ``up_direction``, which is ``Vector2.UP`` by default. This value is always positive.
  46. ----
  47. .. _class_KinematicCollision2D_method_get_collider:
  48. - :ref:`Object<class_Object>` **get_collider** **(** **)** |const|
  49. Returns the colliding body's attached :ref:`Object<class_Object>`.
  50. ----
  51. .. _class_KinematicCollision2D_method_get_collider_id:
  52. - :ref:`int<class_int>` **get_collider_id** **(** **)** |const|
  53. 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>`.
  54. ----
  55. .. _class_KinematicCollision2D_method_get_collider_rid:
  56. - :ref:`RID<class_RID>` **get_collider_rid** **(** **)** |const|
  57. Returns the colliding body's :ref:`RID<class_RID>` used by the :ref:`PhysicsServer2D<class_PhysicsServer2D>`.
  58. ----
  59. .. _class_KinematicCollision2D_method_get_collider_shape:
  60. - :ref:`Object<class_Object>` **get_collider_shape** **(** **)** |const|
  61. Returns the colliding body's shape.
  62. ----
  63. .. _class_KinematicCollision2D_method_get_collider_shape_index:
  64. - :ref:`int<class_int>` **get_collider_shape_index** **(** **)** |const|
  65. Returns the colliding body's shape index. See :ref:`CollisionObject2D<class_CollisionObject2D>`.
  66. ----
  67. .. _class_KinematicCollision2D_method_get_collider_velocity:
  68. - :ref:`Vector2<class_Vector2>` **get_collider_velocity** **(** **)** |const|
  69. Returns the colliding body's velocity.
  70. ----
  71. .. _class_KinematicCollision2D_method_get_local_shape:
  72. - :ref:`Object<class_Object>` **get_local_shape** **(** **)** |const|
  73. Returns the moving object's colliding shape.
  74. ----
  75. .. _class_KinematicCollision2D_method_get_normal:
  76. - :ref:`Vector2<class_Vector2>` **get_normal** **(** **)** |const|
  77. Returns the colliding body's shape's normal at the point of collision.
  78. ----
  79. .. _class_KinematicCollision2D_method_get_position:
  80. - :ref:`Vector2<class_Vector2>` **get_position** **(** **)** |const|
  81. Returns the point of collision in global coordinates.
  82. ----
  83. .. _class_KinematicCollision2D_method_get_remainder:
  84. - :ref:`Vector2<class_Vector2>` **get_remainder** **(** **)** |const|
  85. Returns the moving object's remaining movement vector.
  86. ----
  87. .. _class_KinematicCollision2D_method_get_travel:
  88. - :ref:`Vector2<class_Vector2>` **get_travel** **(** **)** |const|
  89. Returns the moving object's travel before collision.
  90. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  91. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  92. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  93. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  94. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  95. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`