123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
- .. _class_KinematicBody2D:
- KinematicBody2D
- ===============
- **Inherits:** :ref:`PhysicsBody2D<class_physicsbody2d>` **<** :ref:`CollisionObject2D<class_collisionobject2d>` **<** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
- **Category:** Core
- Brief Description
- -----------------
- Kinematic body 2D node.
- Member Functions
- ----------------
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Variant<class_variant>` | :ref:`get_collider<class_KinematicBody2D_get_collider>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Variant<class_variant>` | :ref:`get_collider_metadata<class_KinematicBody2D_get_collider_metadata>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_collider_shape<class_KinematicBody2D_get_collider_shape>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`get_collider_velocity<class_KinematicBody2D_get_collider_velocity>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`get_collision_margin<class_KinematicBody2D_get_collision_margin>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`get_collision_normal<class_KinematicBody2D_get_collision_normal>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`get_collision_pos<class_KinematicBody2D_get_collision_pos>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`get_travel<class_KinematicBody2D_get_travel>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_colliding<class_KinematicBody2D_is_colliding>` **(** **)** const |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`move<class_KinematicBody2D_move>` **(** :ref:`Vector2<class_vector2>` rel_vec **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector2<class_vector2>` | :ref:`move_to<class_KinematicBody2D_move_to>` **(** :ref:`Vector2<class_vector2>` position **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`revert_motion<class_KinematicBody2D_revert_motion>` **(** **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_collision_margin<class_KinematicBody2D_set_collision_margin>` **(** :ref:`float<class_float>` pixels **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`test_move<class_KinematicBody2D_test_move>` **(** :ref:`Vector2<class_vector2>` rel_vec **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`test_move_from<class_KinematicBody2D_test_move_from>` **(** :ref:`Matrix32<class_matrix32>` from, :ref:`Vector2<class_vector2>` rel_vec **)** |
- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
- Description
- -----------
- Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all (to other types of bodies, such a character or a rigid body, these are the same as a static body). They have however, two main uses:
- Simulated Motion: When these bodies are moved manually, either from code or from an AnimationPlayer (with process mode set to fixed), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc).
- Kinematic Characters: KinematicBody2D also has an api for moving objects (the :ref:`move<class_KinematicBody2D_move>` method) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
- Member Function Description
- ---------------------------
- .. _class_KinematicBody2D_get_collider:
- - :ref:`Variant<class_variant>` **get_collider** **(** **)** const
- Return the body that collided with this one.
- .. _class_KinematicBody2D_get_collider_metadata:
- - :ref:`Variant<class_variant>` **get_collider_metadata** **(** **)** const
- Return the metadata of the shape that collided with this body. If there is no collision, it will return 0, so collisions must be checked first with :ref:`is_colliding<class_KinematicBody2D_is_colliding>`. Additionally, this metadata can not be set with :ref:`Object.set_meta<class_Object_set_meta>`, it must be set with :ref:`Physics2DServer.body_set_shape_metadata<class_Physics2DServer_body_set_shape_metadata>`.
- .. _class_KinematicBody2D_get_collider_shape:
- - :ref:`int<class_int>` **get_collider_shape** **(** **)** const
- Return the shape index from the body that collided with this one. If there is no collision, this method will return 0, so collisions must be checked first with :ref:`is_colliding<class_KinematicBody2D_is_colliding>`.
- .. _class_KinematicBody2D_get_collider_velocity:
- - :ref:`Vector2<class_vector2>` **get_collider_velocity** **(** **)** const
- Return the velocity of the body that collided with this one.
- .. _class_KinematicBody2D_get_collision_margin:
- - :ref:`float<class_float>` **get_collision_margin** **(** **)** const
- Return the collision margin for this object.
- .. _class_KinematicBody2D_get_collision_normal:
- - :ref:`Vector2<class_vector2>` **get_collision_normal** **(** **)** const
- Return the normal of the surface the body collided with. This is useful to implement sliding along a surface.
- .. _class_KinematicBody2D_get_collision_pos:
- - :ref:`Vector2<class_vector2>` **get_collision_pos** **(** **)** const
- Return the point in space where the body is touching another. If there is no collision, this method will return (0,0), so collisions must be checked first with :ref:`is_colliding<class_KinematicBody2D_is_colliding>`.
- .. _class_KinematicBody2D_get_travel:
- - :ref:`Vector2<class_vector2>` **get_travel** **(** **)** const
- Return the last movement done by the body.
- .. _class_KinematicBody2D_is_colliding:
- - :ref:`bool<class_bool>` **is_colliding** **(** **)** const
- Return whether the body is colliding with another.
- .. _class_KinematicBody2D_move:
- - :ref:`Vector2<class_vector2>` **move** **(** :ref:`Vector2<class_vector2>` rel_vec **)**
- Move the body in the given direction, stopping if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
- .. _class_KinematicBody2D_move_to:
- - :ref:`Vector2<class_vector2>` **move_to** **(** :ref:`Vector2<class_vector2>` position **)**
- Move the body to the given position. This is not a teleport, and the body will stop if there is an obstacle. The returned vector is how much movement was remaining before being stopped.
- .. _class_KinematicBody2D_revert_motion:
- - void **revert_motion** **(** **)**
- Undo the last movement done by the body.
- .. _class_KinematicBody2D_set_collision_margin:
- - void **set_collision_margin** **(** :ref:`float<class_float>` pixels **)**
- Set the collision margin for this object. A collision margin is an amount (in pixels) that all shapes will grow when computing collisions, to account for numerical imprecision.
- .. _class_KinematicBody2D_test_move:
- - :ref:`bool<class_bool>` **test_move** **(** :ref:`Vector2<class_vector2>` rel_vec **)**
- Return true if there would be a collision if the body moved in the given direction.
- .. _class_KinematicBody2D_test_move_from:
- - :ref:`bool<class_bool>` **test_move_from** **(** :ref:`Matrix32<class_matrix32>` from, :ref:`Vector2<class_vector2>` rel_vec **)**
|