virtualx-engine-docs/_sources/classes/class_kinematiccollision2d.rst.txt
2024-10-23 09:41:33 -07:00

289 lines
11 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/KinematicCollision2D.xml.
.. _class_KinematicCollision2D:
KinematicCollision2D
====================
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
Collision data for :ref:`KinematicBody2D<class_KinematicBody2D>` collisions.
.. rst-class:: classref-introduction-group
Description
-----------
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.
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.
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Object<class_Object>` | :ref:`collider<class_KinematicCollision2D_property_collider>` | |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`int<class_int>` | :ref:`collider_id<class_KinematicCollision2D_property_collider_id>` | ``0`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Variant<class_Variant>` | :ref:`collider_metadata<class_KinematicCollision2D_property_collider_metadata>` | |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`RID<class_RID>` | :ref:`collider_rid<class_KinematicCollision2D_property_collider_rid>` | |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Object<class_Object>` | :ref:`collider_shape<class_KinematicCollision2D_property_collider_shape>` | |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`int<class_int>` | :ref:`collider_shape_index<class_KinematicCollision2D_property_collider_shape_index>` | ``0`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`collider_velocity<class_KinematicCollision2D_property_collider_velocity>` | ``Vector2( 0, 0 )`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Object<class_Object>` | :ref:`local_shape<class_KinematicCollision2D_property_local_shape>` | |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`normal<class_KinematicCollision2D_property_normal>` | ``Vector2( 0, 0 )`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`position<class_KinematicCollision2D_property_position>` | ``Vector2( 0, 0 )`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`remainder<class_KinematicCollision2D_property_remainder>` | ``Vector2( 0, 0 )`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`travel<class_KinematicCollision2D_property_travel>` | ``Vector2( 0, 0 )`` |
+-------------------------------+---------------------------------------------------------------------------------------+---------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_angle<class_KinematicCollision2D_method_get_angle>` **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2( 0, -1 ) **)** |const| |
+---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_KinematicCollision2D_property_collider:
.. rst-class:: classref-property
:ref:`Object<class_Object>` **collider**
.. rst-class:: classref-property-setget
- :ref:`Object<class_Object>` **get_collider** **(** **)**
The colliding body.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_id:
.. rst-class:: classref-property
:ref:`int<class_int>` **collider_id** = ``0``
.. rst-class:: classref-property-setget
- :ref:`int<class_int>` **get_collider_id** **(** **)**
The colliding body's unique instance ID. See :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_metadata:
.. rst-class:: classref-property
:ref:`Variant<class_Variant>` **collider_metadata**
.. rst-class:: classref-property-setget
- :ref:`Variant<class_Variant>` **get_collider_metadata** **(** **)**
The colliding body's metadata. See :ref:`Object<class_Object>`.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_rid:
.. rst-class:: classref-property
:ref:`RID<class_RID>` **collider_rid**
.. rst-class:: classref-property-setget
- :ref:`RID<class_RID>` **get_collider_rid** **(** **)**
The colliding body's :ref:`RID<class_RID>` used by the :ref:`Physics2DServer<class_Physics2DServer>`.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_shape:
.. rst-class:: classref-property
:ref:`Object<class_Object>` **collider_shape**
.. rst-class:: classref-property-setget
- :ref:`Object<class_Object>` **get_collider_shape** **(** **)**
The colliding body's shape.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_shape_index:
.. rst-class:: classref-property
:ref:`int<class_int>` **collider_shape_index** = ``0``
.. rst-class:: classref-property-setget
- :ref:`int<class_int>` **get_collider_shape_index** **(** **)**
The colliding shape's index. See :ref:`CollisionObject2D<class_CollisionObject2D>`.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_collider_velocity:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **collider_velocity** = ``Vector2( 0, 0 )``
.. rst-class:: classref-property-setget
- :ref:`Vector2<class_Vector2>` **get_collider_velocity** **(** **)**
The colliding object's velocity.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_local_shape:
.. rst-class:: classref-property
:ref:`Object<class_Object>` **local_shape**
.. rst-class:: classref-property-setget
- :ref:`Object<class_Object>` **get_local_shape** **(** **)**
The moving object's colliding shape.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_normal:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **normal** = ``Vector2( 0, 0 )``
.. rst-class:: classref-property-setget
- :ref:`Vector2<class_Vector2>` **get_normal** **(** **)**
The colliding body's shape's normal at the point of collision.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_position:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **position** = ``Vector2( 0, 0 )``
.. rst-class:: classref-property-setget
- :ref:`Vector2<class_Vector2>` **get_position** **(** **)**
The point of collision, in global coordinates.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_remainder:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **remainder** = ``Vector2( 0, 0 )``
.. rst-class:: classref-property-setget
- :ref:`Vector2<class_Vector2>` **get_remainder** **(** **)**
The moving object's remaining movement vector.
.. rst-class:: classref-item-separator
----
.. _class_KinematicCollision2D_property_travel:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **travel** = ``Vector2( 0, 0 )``
.. rst-class:: classref-property-setget
- :ref:`Vector2<class_Vector2>` **get_travel** **(** **)**
The distance the moving object traveled before collision.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_KinematicCollision2D_method_get_angle:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_angle** **(** :ref:`Vector2<class_Vector2>` up_direction=Vector2( 0, -1 ) **)** |const|
The collision angle according to ``up_direction``, which is ``Vector2.UP`` by default. This value is always positive.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`