class_kinematiccollision2d.rst 8.7 KB

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