.. 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` **<** :ref:`CollisionObject2D` **<** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Kinematic body 2D node. Member Functions ---------------- +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_collider` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_collider_metadata` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_collider_shape` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_collider_velocity` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_collision_margin` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_collision_normal` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_collision_pos` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_move_and_slide_colliders` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_travel` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_colliding` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_move_and_slide_on_ceiling` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_move_and_slide_on_floor` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_move_and_slide_on_wall` **(** **)** const | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`move` **(** :ref:`Vector2` rel_vec **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`move_and_slide` **(** :ref:`Vector2` linear_velocity, :ref:`Vector2` floor_normal=Vector2(0, 0), :ref:`float` slope_stop_min_velocity=5, :ref:`int` max_bounces=4 **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`move_to` **(** :ref:`Vector2` position **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`revert_motion` **(** **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_collision_margin` **(** :ref:`float` pixels **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`test_move` **(** :ref:`Vector2` rel_vec **)** | +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`test_move_from` **(** :ref:`Matrix32` from, :ref:`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` 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_collision_collider: - :ref:`Variant` **get_collider** **(** **)** const .. _class_KinematicBody2D_get_collision_collider_id: - :ref:`int` **get_collision_collider_id** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_collider_metadata: - :ref:`Variant` **get_collision_collider_metadata** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_collider_shape: - :ref:`Object` **get_collision_collider_shape** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_collider_shape_index: - :ref:`int` **get_collision_collider_shape_index** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_collider_velocity: - :ref:`Vector2` **get_collision_collider_velocity** **(** :ref:`int` collision **)** const Return the velocity of the body that collided with this one. .. _class_KinematicBody2D_get_collision_count: - :ref:`int` **get_collision_count** **(** **)** const .. _class_KinematicBody2D_get_collision_local_shape: - :ref:`Object` **get_collision_local_shape** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_normal: - :ref:`Vector2` **get_collision_normal** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_position: - :ref:`Vector2` **get_collision_position** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_remainder: - :ref:`Vector2` **get_collision_remainder** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_collision_travel: - :ref:`Vector2` **get_collision_travel** **(** :ref:`int` collision **)** const .. _class_KinematicBody2D_get_floor_velocity: .. _class_KinematicBody2D_get_move_and_slide_colliders: - :ref:`Array` **get_move_and_slide_colliders** **(** **)** const .. _class_KinematicBody2D_get_travel: .. _class_KinematicBody2D_get_safe_margin: - :ref:`float` **get_safe_margin** **(** **)** const .. _class_KinematicBody2D_is_on_ceiling: - :ref:`bool` **is_on_ceiling** **(** **)** const .. _class_KinematicBody2D_is_on_floor: - :ref:`bool` **is_on_floor** **(** **)** const .. _class_KinematicBody2D_is_on_wall: - :ref:`bool` **is_on_wall** **(** **)** const .. _class_KinematicBody2D_is_move_and_slide_on_ceiling: - :ref:`bool` **is_move_and_slide_on_ceiling** **(** **)** const .. _class_KinematicBody2D_is_move_and_slide_on_floor: - :ref:`bool` **is_move_and_slide_on_floor** **(** **)** const .. _class_KinematicBody2D_is_move_and_slide_on_wall: - :ref:`bool` **is_move_and_slide_on_wall** **(** **)** const .. _class_KinematicBody2D_move: - :ref:`Dictionary` **move** **(** :ref:`Vector2` rel_vec **)** Move the body in the given direction, stopping if there is an obstacle. If as a result of a movement there will be any collision then informations about this collision will be in returned dictionary. Dictionary will contains those keys: - "position" - collision position - "normal" - collision normal - "local_shape" - id of this kinematic body shape that took part in a collision - "travel" - traveled movement before being stopped .. _class_KinematicBody2D_move_and_slide: - :ref:`Vector2` **move_and_slide** **(** :ref:`Vector2` linear_velocity, :ref:`Vector2` floor_normal=Vector2(0, 0), :ref:`float` slope_stop_min_velocity=5, :ref:`int` max_bounces=4 **)** .. _class_KinematicBody2D_move_to: - "collider_id" - id of the collider, it can be used when dealing with :ref:`Physics2DServer` - "collider" - colliding body - "collider_shape_index" - index of the colliding shape, inside collider body "collider_metadata" If the body did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. Please note that this method is less user friendly than :ref:`move_and_slide`. If you don't want to program each edge case manually, then it's recommended to use :ref:`move_and_slide` instead. .. _class_KinematicBody2D_move_and_slide: - :ref:`Vector2` **move_and_slide** **(** :ref:`Vector2` linear_velocity, :ref:`Vector2` floor_normal=4, :ref:`float` slope_stop_min_velocity=5, :ref:`int` max_bounces=Vector2( 0, 0 ), :ref:`float` floor_max_angle=null **)** .. _class_KinematicBody2D_set_safe_margin: - void **set_safe_margin** **(** :ref:`float` pixels **)** .. _class_KinematicBody2D_test_move: - :ref:`bool` **test_move** **(** :ref:`Transform2D` from, :ref:`Vector2` rel_vec **)** Return true if there would be a collision if the body moved from the given point in the given direction. .. _class_KinematicBody2D_test_move_from: - :ref:`bool` **test_move_from** **(** :ref:`Matrix32` from, :ref:`Vector2` rel_vec **)**