mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
classref: Sync with latest 4.0-dev
This commit is contained in:
239
classes/class_physicsbody3d.rst
Normal file
239
classes/class_physicsbody3d.rst
Normal file
@@ -0,0 +1,239 @@
|
||||
:github_url: hide
|
||||
|
||||
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
||||
.. DO NOT EDIT THIS FILE, but the PhysicsBody3D.xml source instead.
|
||||
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
||||
|
||||
.. _class_PhysicsBody3D:
|
||||
|
||||
PhysicsBody3D
|
||||
=============
|
||||
|
||||
**Inherits:** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||||
|
||||
**Inherited By:** :ref:`CharacterBody3D<class_CharacterBody3D>`, :ref:`PhysicalBone3D<class_PhysicalBone3D>`, :ref:`RigidDynamicBody3D<class_RigidDynamicBody3D>`, :ref:`StaticBody3D<class_StaticBody3D>`
|
||||
|
||||
Base class for all objects affected by physics in 3D space.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
PhysicsBody3D is an abstract base class for implementing a physics body. All \*Body types inherit from it.
|
||||
|
||||
Tutorials
|
||||
---------
|
||||
|
||||
- :doc:`../tutorials/physics/physics_introduction`
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_angular_x<class_PhysicsBody3D_property_axis_lock_angular_x>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_angular_y<class_PhysicsBody3D_property_axis_lock_angular_y>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_angular_z<class_PhysicsBody3D_property_axis_lock_angular_z>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_linear_x<class_PhysicsBody3D_property_axis_lock_linear_x>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_linear_y<class_PhysicsBody3D_property_axis_lock_linear_y>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
| :ref:`bool<class_bool>` | :ref:`axis_lock_linear_z<class_PhysicsBody3D_property_axis_lock_linear_z>` | ``false`` |
|
||||
+-------------------------+------------------------------------------------------------------------------+-----------+
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`add_collision_exception_with<class_PhysicsBody3D_method_add_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`get_axis_lock<class_PhysicsBody3D_method_get_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis **)** |const| |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`PhysicsBody3D[]<class_PhysicsBody3D>` | :ref:`get_collision_exceptions<class_PhysicsBody3D_method_get_collision_exceptions>` **(** **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`move_and_collide<class_PhysicsBody3D_method_move_and_collide>` **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`bool<class_bool>` test_only=false, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`remove_collision_exception_with<class_PhysicsBody3D_method_remove_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`set_axis_lock<class_PhysicsBody3D_method_set_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`test_move<class_PhysicsBody3D_method_test_move>` **(** :ref:`Transform3D<class_Transform3D>` from, :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`KinematicCollision3D<class_KinematicCollision3D>` collision=null, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)** |
|
||||
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Property Descriptions
|
||||
---------------------
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_angular_x:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_angular_x**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's rotation in the X axis.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_angular_y:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_angular_y**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's rotation in the Y axis.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_angular_z:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_angular_z**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's rotation in the Z axis.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_linear_x:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_linear_x**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's linear movement in the X axis.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_linear_y:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_linear_y**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's linear movement in the Y axis.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_property_axis_lock_linear_z:
|
||||
|
||||
- :ref:`bool<class_bool>` **axis_lock_linear_z**
|
||||
|
||||
+-----------+----------------------+
|
||||
| *Default* | ``false`` |
|
||||
+-----------+----------------------+
|
||||
| *Setter* | set_axis_lock(value) |
|
||||
+-----------+----------------------+
|
||||
| *Getter* | get_axis_lock() |
|
||||
+-----------+----------------------+
|
||||
|
||||
Lock the body's linear movement in the Z axis.
|
||||
|
||||
Method Descriptions
|
||||
-------------------
|
||||
|
||||
.. _class_PhysicsBody3D_method_add_collision_exception_with:
|
||||
|
||||
- void **add_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
|
||||
|
||||
Adds a body to the list of bodies that this body can't collide with.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_get_axis_lock:
|
||||
|
||||
- :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis **)** |const|
|
||||
|
||||
Returns ``true`` if the specified linear or rotational ``axis`` is locked.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_get_collision_exceptions:
|
||||
|
||||
- :ref:`PhysicsBody3D[]<class_PhysicsBody3D>` **get_collision_exceptions** **(** **)**
|
||||
|
||||
Returns an array of nodes that were added as collision exceptions for this body.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_move_and_collide:
|
||||
|
||||
- :ref:`KinematicCollision3D<class_KinematicCollision3D>` **move_and_collide** **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`bool<class_bool>` test_only=false, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)**
|
||||
|
||||
Moves the body along the vector ``linear_velocity``. This method should be used in :ref:`Node._physics_process<class_Node_method__physics_process>` (or in a method called by :ref:`Node._physics_process<class_Node_method__physics_process>`), as it uses the physics step's ``delta`` value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
|
||||
|
||||
The body will stop if it collides. Returns a :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains information about the collision.
|
||||
|
||||
If ``test_only`` is ``true``, the body does not move but the would-be collision information is given.
|
||||
|
||||
``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).
|
||||
|
||||
``max_collisions`` allows to retrieve more than one collision result.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_remove_collision_exception_with:
|
||||
|
||||
- void **remove_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
|
||||
|
||||
Removes a body from the list of bodies that this body can't collide with.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_set_axis_lock:
|
||||
|
||||
- void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer3D_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
|
||||
|
||||
Locks or unlocks the specified linear or rotational ``axis`` depending on the value of ``lock``.
|
||||
|
||||
----
|
||||
|
||||
.. _class_PhysicsBody3D_method_test_move:
|
||||
|
||||
- :ref:`bool<class_bool>` **test_move** **(** :ref:`Transform3D<class_Transform3D>` from, :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`KinematicCollision3D<class_KinematicCollision3D>` collision=null, :ref:`float<class_float>` safe_margin=0.001, :ref:`int<class_int>` max_collisions=1 **)**
|
||||
|
||||
Checks for collisions without moving the body. This method should be used in :ref:`Node._physics_process<class_Node_method__physics_process>` (or in a method called by :ref:`Node._physics_process<class_Node_method__physics_process>`), as it uses the physics step's ``delta`` value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
|
||||
|
||||
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 ``linear_velocity``. Returns ``true`` if a collision would occur.
|
||||
|
||||
``collision`` is an optional object of type :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains additional information about the collision (should there be one).
|
||||
|
||||
``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).
|
||||
|
||||
``max_collisions`` allows to retrieve more than one collision result.
|
||||
|
||||
.. |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.)`
|
||||
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||||
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
||||
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|
||||
Reference in New Issue
Block a user