class_physicsbody3d.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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/PhysicsBody3D.xml.
  6. .. _class_PhysicsBody3D:
  7. PhysicsBody3D
  8. =============
  9. **Inherits:** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`CharacterBody3D<class_CharacterBody3D>`, :ref:`PhysicalBone3D<class_PhysicalBone3D>`, :ref:`RigidDynamicBody3D<class_RigidDynamicBody3D>`, :ref:`StaticBody3D<class_StaticBody3D>`
  11. Base class for all objects affected by physics in 3D space.
  12. Description
  13. -----------
  14. PhysicsBody3D is an abstract base class for implementing a physics body. All \*Body types inherit from it.
  15. Tutorials
  16. ---------
  17. - :doc:`Physics introduction <../tutorials/physics/physics_introduction>`
  18. Properties
  19. ----------
  20. +-------------------------+------------------------------------------------------------------------------+-----------+
  21. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_x<class_PhysicsBody3D_property_axis_lock_angular_x>` | ``false`` |
  22. +-------------------------+------------------------------------------------------------------------------+-----------+
  23. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_y<class_PhysicsBody3D_property_axis_lock_angular_y>` | ``false`` |
  24. +-------------------------+------------------------------------------------------------------------------+-----------+
  25. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_z<class_PhysicsBody3D_property_axis_lock_angular_z>` | ``false`` |
  26. +-------------------------+------------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_x<class_PhysicsBody3D_property_axis_lock_linear_x>` | ``false`` |
  28. +-------------------------+------------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_y<class_PhysicsBody3D_property_axis_lock_linear_y>` | ``false`` |
  30. +-------------------------+------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_z<class_PhysicsBody3D_property_axis_lock_linear_z>` | ``false`` |
  32. +-------------------------+------------------------------------------------------------------------------+-----------+
  33. Methods
  34. -------
  35. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`add_collision_exception_with<class_PhysicsBody3D_method_add_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  37. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`get_axis_lock<class_PhysicsBody3D_method_get_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis **)** |const| |
  39. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`PhysicsBody3D[]<class_PhysicsBody3D>` | :ref:`get_collision_exceptions<class_PhysicsBody3D_method_get_collision_exceptions>` **(** **)** |
  41. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`move_and_collide<class_PhysicsBody3D_method_move_and_collide>` **(** :ref:`Vector3<class_Vector3>` distance, :ref:`bool<class_bool>` test_only=false, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)** |
  43. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_collision_exception_with<class_PhysicsBody3D_method_remove_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  45. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_axis_lock<class_PhysicsBody3D_method_set_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)** |
  47. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`test_move<class_PhysicsBody3D_method_test_move>` **(** :ref:`Transform3D<class_Transform3D>` from, :ref:`Vector3<class_Vector3>` distance, :ref:`KinematicCollision3D<class_KinematicCollision3D>` collision=null, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)** |
  49. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. Property Descriptions
  51. ---------------------
  52. .. _class_PhysicsBody3D_property_axis_lock_angular_x:
  53. - :ref:`bool<class_bool>` **axis_lock_angular_x**
  54. +-----------+----------------------+
  55. | *Default* | ``false`` |
  56. +-----------+----------------------+
  57. | *Setter* | set_axis_lock(value) |
  58. +-----------+----------------------+
  59. | *Getter* | get_axis_lock() |
  60. +-----------+----------------------+
  61. Lock the body's rotation in the X axis.
  62. ----
  63. .. _class_PhysicsBody3D_property_axis_lock_angular_y:
  64. - :ref:`bool<class_bool>` **axis_lock_angular_y**
  65. +-----------+----------------------+
  66. | *Default* | ``false`` |
  67. +-----------+----------------------+
  68. | *Setter* | set_axis_lock(value) |
  69. +-----------+----------------------+
  70. | *Getter* | get_axis_lock() |
  71. +-----------+----------------------+
  72. Lock the body's rotation in the Y axis.
  73. ----
  74. .. _class_PhysicsBody3D_property_axis_lock_angular_z:
  75. - :ref:`bool<class_bool>` **axis_lock_angular_z**
  76. +-----------+----------------------+
  77. | *Default* | ``false`` |
  78. +-----------+----------------------+
  79. | *Setter* | set_axis_lock(value) |
  80. +-----------+----------------------+
  81. | *Getter* | get_axis_lock() |
  82. +-----------+----------------------+
  83. Lock the body's rotation in the Z axis.
  84. ----
  85. .. _class_PhysicsBody3D_property_axis_lock_linear_x:
  86. - :ref:`bool<class_bool>` **axis_lock_linear_x**
  87. +-----------+----------------------+
  88. | *Default* | ``false`` |
  89. +-----------+----------------------+
  90. | *Setter* | set_axis_lock(value) |
  91. +-----------+----------------------+
  92. | *Getter* | get_axis_lock() |
  93. +-----------+----------------------+
  94. Lock the body's linear movement in the X axis.
  95. ----
  96. .. _class_PhysicsBody3D_property_axis_lock_linear_y:
  97. - :ref:`bool<class_bool>` **axis_lock_linear_y**
  98. +-----------+----------------------+
  99. | *Default* | ``false`` |
  100. +-----------+----------------------+
  101. | *Setter* | set_axis_lock(value) |
  102. +-----------+----------------------+
  103. | *Getter* | get_axis_lock() |
  104. +-----------+----------------------+
  105. Lock the body's linear movement in the Y axis.
  106. ----
  107. .. _class_PhysicsBody3D_property_axis_lock_linear_z:
  108. - :ref:`bool<class_bool>` **axis_lock_linear_z**
  109. +-----------+----------------------+
  110. | *Default* | ``false`` |
  111. +-----------+----------------------+
  112. | *Setter* | set_axis_lock(value) |
  113. +-----------+----------------------+
  114. | *Getter* | get_axis_lock() |
  115. +-----------+----------------------+
  116. Lock the body's linear movement in the Z axis.
  117. Method Descriptions
  118. -------------------
  119. .. _class_PhysicsBody3D_method_add_collision_exception_with:
  120. - void **add_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  121. Adds a body to the list of bodies that this body can't collide with.
  122. ----
  123. .. _class_PhysicsBody3D_method_get_axis_lock:
  124. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis **)** |const|
  125. Returns ``true`` if the specified linear or rotational ``axis`` is locked.
  126. ----
  127. .. _class_PhysicsBody3D_method_get_collision_exceptions:
  128. - :ref:`PhysicsBody3D[]<class_PhysicsBody3D>` **get_collision_exceptions** **(** **)**
  129. Returns an array of nodes that were added as collision exceptions for this body.
  130. ----
  131. .. _class_PhysicsBody3D_method_move_and_collide:
  132. - :ref:`KinematicCollision3D<class_KinematicCollision3D>` **move_and_collide** **(** :ref:`Vector3<class_Vector3>` distance, :ref:`bool<class_bool>` test_only=false, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)**
  133. Moves the body along the vector ``distance``. In order to be frame rate independent in :ref:`Node._physics_process<class_Node_method__physics_process>` or :ref:`Node._process<class_Node_method__process>`, ``distance`` should be computed using ``delta``.
  134. The body will stop if it collides. Returns a :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains information about the collision when stopped, or when touching another body along the motion.
  135. If ``test_only`` is ``true``, the body does not move but the would-be collision information is given.
  136. \ ``safe_margin`` is the extra margin used for collision recovery (see :ref:`CharacterBody3D.collision/safe_margin<class_CharacterBody3D_property_collision/safe_margin>` for more details).
  137. \ ``max_collisions`` allows to retrieve more than one collision result.
  138. ----
  139. .. _class_PhysicsBody3D_method_remove_collision_exception_with:
  140. - void **remove_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  141. Removes a body from the list of bodies that this body can't collide with.
  142. ----
  143. .. _class_PhysicsBody3D_method_set_axis_lock:
  144. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  145. Locks or unlocks the specified linear or rotational ``axis`` depending on the value of ``lock``.
  146. ----
  147. .. _class_PhysicsBody3D_method_test_move:
  148. - :ref:`bool<class_bool>` **test_move** **(** :ref:`Transform3D<class_Transform3D>` from, :ref:`Vector3<class_Vector3>` distance, :ref:`KinematicCollision3D<class_KinematicCollision3D>` collision=null, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)**
  149. Checks for collisions without moving the body. In order to be frame rate independent in :ref:`Node._physics_process<class_Node_method__physics_process>` or :ref:`Node._process<class_Node_method__process>`, ``distance`` should be computed using ``delta``.
  150. Virtually sets the node's position, scale and rotation to that of the given :ref:`Transform3D<class_Transform3D>`, then tries to move the body along the vector ``distance``. Returns ``true`` if a collision would stop the body from moving along the whole path.
  151. \ ``collision`` is an optional object of type :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains additional information about the collision when stopped, or when touching another body along the motion.
  152. \ ``safe_margin`` is the extra margin used for collision recovery (see :ref:`CharacterBody3D.collision/safe_margin<class_CharacterBody3D_property_collision/safe_margin>` for more details).
  153. \ ``max_collisions`` allows to retrieve more than one collision result.
  154. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  155. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  156. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  157. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  158. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  159. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`