class_kinematicbody.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_KinematicBody:
  4. KinematicBody
  5. =============
  6. **Inherits:** :ref:`PhysicsBody<class_physicsbody>` **<** :ref:`CollisionObject<class_collisionobject>` **<** :ref:`Spatial<class_spatial>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Kinematic body 3D node.
  11. Member Functions
  12. ----------------
  13. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`bool<class_bool>` | :ref:`can_collide_with_character_bodies<class_KinematicBody_can_collide_with_character_bodies>` **(** **)** const |
  15. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`can_collide_with_kinematic_bodies<class_KinematicBody_can_collide_with_kinematic_bodies>` **(** **)** const |
  17. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`can_collide_with_rigid_bodies<class_KinematicBody_can_collide_with_rigid_bodies>` **(** **)** const |
  19. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`can_collide_with_static_bodies<class_KinematicBody_can_collide_with_static_bodies>` **(** **)** const |
  21. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`can_teleport_to<class_KinematicBody_can_teleport_to>` **(** :ref:`Vector3<class_vector3>` position **)** |
  23. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Variant<class_variant>` | :ref:`get_collider<class_KinematicBody_get_collider>` **(** **)** const |
  25. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_collider_shape<class_KinematicBody_get_collider_shape>` **(** **)** const |
  27. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Vector3<class_vector3>` | :ref:`get_collider_velocity<class_KinematicBody_get_collider_velocity>` **(** **)** const |
  29. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`get_collision_margin<class_KinematicBody_get_collision_margin>` **(** **)** const |
  31. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector3<class_vector3>` | :ref:`get_collision_normal<class_KinematicBody_get_collision_normal>` **(** **)** const |
  33. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Vector3<class_vector3>` | :ref:`get_collision_pos<class_KinematicBody_get_collision_pos>` **(** **)** const |
  35. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`is_colliding<class_KinematicBody_is_colliding>` **(** **)** const |
  37. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Vector3<class_vector3>` | :ref:`move<class_KinematicBody_move>` **(** :ref:`Vector3<class_vector3>` rel_vec **)** |
  39. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Vector3<class_vector3>` | :ref:`move_to<class_KinematicBody_move_to>` **(** :ref:`Vector3<class_vector3>` position **)** |
  41. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_collide_with_character_bodies<class_KinematicBody_set_collide_with_character_bodies>` **(** :ref:`bool<class_bool>` enable **)** |
  43. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_collide_with_kinematic_bodies<class_KinematicBody_set_collide_with_kinematic_bodies>` **(** :ref:`bool<class_bool>` enable **)** |
  45. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_collide_with_rigid_bodies<class_KinematicBody_set_collide_with_rigid_bodies>` **(** :ref:`bool<class_bool>` enable **)** |
  47. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_collide_with_static_bodies<class_KinematicBody_set_collide_with_static_bodies>` **(** :ref:`bool<class_bool>` enable **)** |
  49. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_collision_margin<class_KinematicBody_set_collision_margin>` **(** :ref:`float<class_float>` pixels **)** |
  51. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  52. Description
  53. -----------
  54. 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:
  55. 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).
  56. Kinematic Characters: KinematicBody also has an api for moving objects (the :ref:`move<class_KinematicBody_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.
  57. Member Function Description
  58. ---------------------------
  59. .. _class_KinematicBody_can_collide_with_character_bodies:
  60. - :ref:`bool<class_bool>` **can_collide_with_character_bodies** **(** **)** const
  61. Return if this body can collide with character bodies.
  62. .. _class_KinematicBody_can_collide_with_kinematic_bodies:
  63. - :ref:`bool<class_bool>` **can_collide_with_kinematic_bodies** **(** **)** const
  64. Return if this body can collide with kinematic bodies.
  65. .. _class_KinematicBody_can_collide_with_rigid_bodies:
  66. - :ref:`bool<class_bool>` **can_collide_with_rigid_bodies** **(** **)** const
  67. Return if this body can collide with rigid bodies.
  68. .. _class_KinematicBody_can_collide_with_static_bodies:
  69. - :ref:`bool<class_bool>` **can_collide_with_static_bodies** **(** **)** const
  70. Return if this body can collide with static bodies.
  71. .. _class_KinematicBody_can_teleport_to:
  72. - :ref:`bool<class_bool>` **can_teleport_to** **(** :ref:`Vector3<class_vector3>` position **)**
  73. Returns whether the KinematicBody can be teleported to the destination given as an argument, checking all collision shapes of the body against potential colliders at the destination.
  74. .. _class_KinematicBody_get_collider:
  75. - :ref:`Variant<class_variant>` **get_collider** **(** **)** const
  76. Return the body that collided with this one.
  77. .. _class_KinematicBody_get_collider_shape:
  78. - :ref:`int<class_int>` **get_collider_shape** **(** **)** const
  79. 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_KinematicBody_is_colliding>`.
  80. .. _class_KinematicBody_get_collider_velocity:
  81. - :ref:`Vector3<class_vector3>` **get_collider_velocity** **(** **)** const
  82. Return the velocity of the body that collided with this one.
  83. .. _class_KinematicBody_get_collision_margin:
  84. - :ref:`float<class_float>` **get_collision_margin** **(** **)** const
  85. Return the collision margin for this object.
  86. .. _class_KinematicBody_get_collision_normal:
  87. - :ref:`Vector3<class_vector3>` **get_collision_normal** **(** **)** const
  88. Return the normal of the surface the body collided with. This is useful to implement sliding along a surface.
  89. .. _class_KinematicBody_get_collision_pos:
  90. - :ref:`Vector3<class_vector3>` **get_collision_pos** **(** **)** const
  91. Return the point in space where the body is touching another. If there is no collision, this method will return (0,0,0), so collisions must be checked first with :ref:`is_colliding<class_KinematicBody_is_colliding>`.
  92. .. _class_KinematicBody_is_colliding:
  93. - :ref:`bool<class_bool>` **is_colliding** **(** **)** const
  94. Return whether the body is colliding with another.
  95. .. _class_KinematicBody_move:
  96. - :ref:`Vector3<class_vector3>` **move** **(** :ref:`Vector3<class_vector3>` rel_vec **)**
  97. 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.
  98. .. _class_KinematicBody_move_to:
  99. - :ref:`Vector3<class_vector3>` **move_to** **(** :ref:`Vector3<class_vector3>` position **)**
  100. 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.
  101. .. _class_KinematicBody_set_collide_with_character_bodies:
  102. - void **set_collide_with_character_bodies** **(** :ref:`bool<class_bool>` enable **)**
  103. Set if this body should collide with character bodies.
  104. .. _class_KinematicBody_set_collide_with_kinematic_bodies:
  105. - void **set_collide_with_kinematic_bodies** **(** :ref:`bool<class_bool>` enable **)**
  106. Set if this body should collide with kinematic bodies.
  107. .. _class_KinematicBody_set_collide_with_rigid_bodies:
  108. - void **set_collide_with_rigid_bodies** **(** :ref:`bool<class_bool>` enable **)**
  109. Set if this body should collide with rigid bodies.
  110. .. _class_KinematicBody_set_collide_with_static_bodies:
  111. - void **set_collide_with_static_bodies** **(** :ref:`bool<class_bool>` enable **)**
  112. Set if this body should collide with static bodies.
  113. .. _class_KinematicBody_set_collision_margin:
  114. - void **set_collision_margin** **(** :ref:`float<class_float>` pixels **)**
  115. Set the collision margin for this object. A collision margin is an amount that all shapes will grow when computing collisions, to account for numerical imprecision.