Files
godot-docs-l10n/classes/es/class_rigidbody2d.rst
Rémi Verschelde cf78697eea Add localized class reference as pre-generated RST files
Currently including `zh_CN` and `es` which both have very high completion
ratios. Others will be added once they reach a significant percentage too.

These RST files will be used by godot-docs in place of its `classes` folder
after we sync with https://github.com/godotengine/godot-docs/pull/5458.

The update workflow is manual for now (example for `zh_CN`):

- Build `godotengine/godot` in the branch we currently track (now `3.x`)
- Run `godot --doctool -l zh_CN`
- Run `cd doc && make rst LANGARG=zh_CN`
- Copy `doc/_build/rst/*` to `classes/zh_CN/` here
- Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
2021-12-21 16:07:55 +01:00

627 lines
38 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the RigidBody2D.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_RigidBody2D:
RigidBody2D
===========
**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>`
Un cuerpo que es controlado por el motor de física 2D.
Descripción
----------------------
This node implements simulated 2D physics. You do not control a RigidBody2D directly. Instead, you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties.
A RigidBody2D has 4 behavior :ref:`mode<class_RigidBody2D_property_mode>`\ s: Rigid, Static, Character, and Kinematic.
\ **Note:** You should not change a RigidBody2D's ``position`` or ``linear_velocity`` every frame or even very often. If you need to directly affect the body's state, use :ref:`_integrate_forces<class_RigidBody2D_method__integrate_forces>`, which allows you to directly access the physics state.
Please also keep in mind that physics bodies manage their own transform which overwrites the ones you set. So any direct or indirect transformation (including scaling of the node or its parent) will be visible in the editor only, and immediately reset at runtime.
If you need to override the default physics behavior or add a transformation at runtime, you can write a custom force integration. See :ref:`custom_integrator<class_RigidBody2D_property_custom_integrator>`.
The center of mass is always located at the node's origin without taking into account the :ref:`CollisionShape2D<class_CollisionShape2D>` centroid offsets.
Tutoriales
--------------------
- `2D Physics Platformer Demo <https://godotengine.org/asset-library/asset/119>`__
- `Instancing Demo <https://godotengine.org/asset-library/asset/148>`__
Propiedades
----------------------
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`angular_damp<class_RigidBody2D_property_angular_damp>` | ``-1.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`angular_velocity<class_RigidBody2D_property_angular_velocity>` | ``0.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`applied_force<class_RigidBody2D_property_applied_force>` | ``Vector2( 0, 0 )`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`applied_torque<class_RigidBody2D_property_applied_torque>` | ``0.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`bounce<class_RigidBody2D_property_bounce>` | |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`bool<class_bool>` | :ref:`can_sleep<class_RigidBody2D_property_can_sleep>` | ``true`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`bool<class_bool>` | :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` | ``false`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`int<class_int>` | :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` | ``0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`CCDMode<enum_RigidBody2D_CCDMode>` | :ref:`continuous_cd<class_RigidBody2D_property_continuous_cd>` | ``0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`bool<class_bool>` | :ref:`custom_integrator<class_RigidBody2D_property_custom_integrator>` | ``false`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`friction<class_RigidBody2D_property_friction>` | |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`gravity_scale<class_RigidBody2D_property_gravity_scale>` | ``1.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`inertia<class_RigidBody2D_property_inertia>` | |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`linear_damp<class_RigidBody2D_property_linear_damp>` | ``-1.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`linear_velocity<class_RigidBody2D_property_linear_velocity>` | ``Vector2( 0, 0 )`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`mass<class_RigidBody2D_property_mass>` | ``1.0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`Mode<enum_RigidBody2D_Mode>` | :ref:`mode<class_RigidBody2D_property_mode>` | ``0`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`PhysicsMaterial<class_PhysicsMaterial>` | :ref:`physics_material_override<class_RigidBody2D_property_physics_material_override>` | |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`bool<class_bool>` | :ref:`sleeping<class_RigidBody2D_property_sleeping>` | ``false`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
| :ref:`float<class_float>` | :ref:`weight<class_RigidBody2D_property_weight>` | ``9.8`` |
+-----------------------------------------------+----------------------------------------------------------------------------------------+---------------------+
Métodos
--------------
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_integrate_forces<class_RigidBody2D_method__integrate_forces>` **(** :ref:`Physics2DDirectBodyState<class_Physics2DDirectBodyState>` state **)** |virtual| |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_central_force<class_RigidBody2D_method_add_central_force>` **(** :ref:`Vector2<class_Vector2>` force **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_force<class_RigidBody2D_method_add_force>` **(** :ref:`Vector2<class_Vector2>` offset, :ref:`Vector2<class_Vector2>` force **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_torque<class_RigidBody2D_method_add_torque>` **(** :ref:`float<class_float>` torque **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`apply_central_impulse<class_RigidBody2D_method_apply_central_impulse>` **(** :ref:`Vector2<class_Vector2>` impulse **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`apply_impulse<class_RigidBody2D_method_apply_impulse>` **(** :ref:`Vector2<class_Vector2>` offset, :ref:`Vector2<class_Vector2>` impulse **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`apply_torque_impulse<class_RigidBody2D_method_apply_torque_impulse>` **(** :ref:`float<class_float>` torque **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_colliding_bodies<class_RigidBody2D_method_get_colliding_bodies>` **(** **)** |const| |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_axis_velocity<class_RigidBody2D_method_set_axis_velocity>` **(** :ref:`Vector2<class_Vector2>` axis_velocity **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`test_motion<class_RigidBody2D_method_test_motion>` **(** :ref:`Vector2<class_Vector2>` motion, :ref:`bool<class_bool>` infinite_inertia=true, :ref:`float<class_float>` margin=0.08, :ref:`Physics2DTestMotionResult<class_Physics2DTestMotionResult>` result=null **)** |
+---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Señales
--------------
.. _class_RigidBody2D_signal_body_entered:
- **body_entered** **(** :ref:`Node<class_Node>` body **)**
Emitted when a collision with another :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>` occurs. Requires :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`TileMap<class_TileMap>`\ s are detected if the :ref:`TileSet<class_TileSet>` has Collision :ref:`Shape2D<class_Shape2D>`\ s.
\ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`.
----
.. _class_RigidBody2D_signal_body_exited:
- **body_exited** **(** :ref:`Node<class_Node>` body **)**
Emitted when the collision with another :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>` ends. Requires :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`TileMap<class_TileMap>`\ s are detected if the :ref:`TileSet<class_TileSet>` has Collision :ref:`Shape2D<class_Shape2D>`\ s.
\ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`.
----
.. _class_RigidBody2D_signal_body_shape_entered:
- **body_shape_entered** **(** :ref:`RID<class_RID>` body_rid, :ref:`Node<class_Node>` body, :ref:`int<class_int>` body_shape_index, :ref:`int<class_int>` local_shape_index **)**
Emitted when one of this RigidBody2D's :ref:`Shape2D<class_Shape2D>`\ s collides with another :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`'s :ref:`Shape2D<class_Shape2D>`\ s. Requires :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`TileMap<class_TileMap>`\ s are detected if the :ref:`TileSet<class_TileSet>` has Collision :ref:`Shape2D<class_Shape2D>`\ s.
\ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileSet<class_TileSet>`'s :ref:`CollisionObject2D<class_CollisionObject2D>` used by the :ref:`Physics2DServer<class_Physics2DServer>`.
\ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`.
\ ``body_shape_index`` the index of the :ref:`Shape2D<class_Shape2D>` of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>` used by the :ref:`Physics2DServer<class_Physics2DServer>`. Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node with ``body.shape_owner_get_owner(body_shape_index)``.
\ ``local_shape_index`` the index of the :ref:`Shape2D<class_Shape2D>` of this RigidBody2D used by the :ref:`Physics2DServer<class_Physics2DServer>`. Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node with ``self.shape_owner_get_owner(local_shape_index)``.
----
.. _class_RigidBody2D_signal_body_shape_exited:
- **body_shape_exited** **(** :ref:`RID<class_RID>` body_rid, :ref:`Node<class_Node>` body, :ref:`int<class_int>` body_shape_index, :ref:`int<class_int>` local_shape_index **)**
Emitted when the collision between one of this RigidBody2D's :ref:`Shape2D<class_Shape2D>`\ s and another :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`'s :ref:`Shape2D<class_Shape2D>`\ s ends. Requires :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`TileMap<class_TileMap>`\ s are detected if the :ref:`TileSet<class_TileSet>` has Collision :ref:`Shape2D<class_Shape2D>`\ s.
\ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileSet<class_TileSet>`'s :ref:`CollisionObject2D<class_CollisionObject2D>` used by the :ref:`Physics2DServer<class_Physics2DServer>`.
\ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>`.
\ ``body_shape_index`` the index of the :ref:`Shape2D<class_Shape2D>` of the other :ref:`PhysicsBody2D<class_PhysicsBody2D>` or :ref:`TileMap<class_TileMap>` used by the :ref:`Physics2DServer<class_Physics2DServer>`. Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node with ``body.shape_owner_get_owner(body_shape_index)``.
\ ``local_shape_index`` the index of the :ref:`Shape2D<class_Shape2D>` of this RigidBody2D used by the :ref:`Physics2DServer<class_Physics2DServer>`. Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node with ``self.shape_owner_get_owner(local_shape_index)``.
----
.. _class_RigidBody2D_signal_sleeping_state_changed:
- **sleeping_state_changed** **(** **)**
Emitida cuando el motor físico cambia el estado de sueño del cuerpo.
\ **Nota:** Cambiar el valor :ref:`sleeping<class_RigidBody2D_property_sleeping>` no activará esta señal. Sólo se emite si el motor de física cambia el estado de sueño o si se utiliza ``emit_signal("sleeping_state_changed")``.
Enumeraciones
--------------------------
.. _enum_RigidBody2D_Mode:
.. _class_RigidBody2D_constant_MODE_RIGID:
.. _class_RigidBody2D_constant_MODE_STATIC:
.. _class_RigidBody2D_constant_MODE_CHARACTER:
.. _class_RigidBody2D_constant_MODE_KINEMATIC:
enum **Mode**:
- **MODE_RIGID** = **0** --- Modo rígido. El cuerpo se comporta como un objeto físico. Colisiona con otros cuerpos y responde a las fuerzas que se le aplican. Este es el modo por defecto.
- **MODE_STATIC** = **1** --- Modo estático. El cuerpo se comporta como un :ref:`StaticBody2D<class_StaticBody2D>` y no se mueve.
- **MODE_CHARACTER** = **2** --- Modo de personaje. Similar a :ref:`MODE_RIGID<class_RigidBody2D_constant_MODE_RIGID>`, pero el cuerpo no puede rotar.
- **MODE_KINEMATIC** = **3** --- Modo cinemático. El cuerpo se comporta como un :ref:`KinematicBody2D<class_KinematicBody2D>`, y debe ser movido por un código.
----
.. _enum_RigidBody2D_CCDMode:
.. _class_RigidBody2D_constant_CCD_MODE_DISABLED:
.. _class_RigidBody2D_constant_CCD_MODE_CAST_RAY:
.. _class_RigidBody2D_constant_CCD_MODE_CAST_SHAPE:
enum **CCDMode**:
- **CCD_MODE_DISABLED** = **0** --- Detección de colisión continua desactivada. Es la forma más rápida de detectar colisiones corporales, pero puede pasar por alto pequeños objetos de movimiento rápido.
- **CCD_MODE_CAST_RAY** = **1** --- Detección de colisión continua activada mediante raycasting. Esto es más rápido que el "shapecasting" pero menos preciso.
- **CCD_MODE_CAST_SHAPE** = **2** --- Detección de colisión continua habilitada mediante el uso de "shapecasting". Este es el método CCD más lento y más preciso.
Descripciones de Propiedades
--------------------------------------------------------
.. _class_RigidBody2D_property_angular_damp:
- :ref:`float<class_float>` **angular_damp**
+-----------+-------------------------+
| *Default* | ``-1.0`` |
+-----------+-------------------------+
| *Setter* | set_angular_damp(value) |
+-----------+-------------------------+
| *Getter* | get_angular_damp() |
+-----------+-------------------------+
Damps the body's :ref:`angular_velocity<class_RigidBody2D_property_angular_velocity>`. If ``-1``, the body will use the **Default Angular Damp** defined in **Project > Project Settings > Physics > 2d**.
See :ref:`ProjectSettings.physics/2d/default_angular_damp<class_ProjectSettings_property_physics/2d/default_angular_damp>` for more details about damping.
----
.. _class_RigidBody2D_property_angular_velocity:
- :ref:`float<class_float>` **angular_velocity**
+-----------+-----------------------------+
| *Default* | ``0.0`` |
+-----------+-----------------------------+
| *Setter* | set_angular_velocity(value) |
+-----------+-----------------------------+
| *Getter* | get_angular_velocity() |
+-----------+-----------------------------+
The body's rotational velocity in *radians* per second.
----
.. _class_RigidBody2D_property_applied_force:
- :ref:`Vector2<class_Vector2>` **applied_force**
+-----------+--------------------------+
| *Default* | ``Vector2( 0, 0 )`` |
+-----------+--------------------------+
| *Setter* | set_applied_force(value) |
+-----------+--------------------------+
| *Getter* | get_applied_force() |
+-----------+--------------------------+
La fuerza total aplicada al cuerpo.
----
.. _class_RigidBody2D_property_applied_torque:
- :ref:`float<class_float>` **applied_torque**
+-----------+---------------------------+
| *Default* | ``0.0`` |
+-----------+---------------------------+
| *Setter* | set_applied_torque(value) |
+-----------+---------------------------+
| *Getter* | get_applied_torque() |
+-----------+---------------------------+
El torque total aplicado al cuerpo.
----
.. _class_RigidBody2D_property_bounce:
- :ref:`float<class_float>` **bounce**
+----------+-------------------+
| *Setter* | set_bounce(value) |
+----------+-------------------+
| *Getter* | get_bounce() |
+----------+-------------------+
The body's bounciness. Values range from ``0`` (no bounce) to ``1`` (full bounciness).
Deprecated, use :ref:`PhysicsMaterial.bounce<class_PhysicsMaterial_property_bounce>` instead via :ref:`physics_material_override<class_RigidBody2D_property_physics_material_override>`.
----
.. _class_RigidBody2D_property_can_sleep:
- :ref:`bool<class_bool>` **can_sleep**
+-----------+----------------------+
| *Default* | ``true`` |
+-----------+----------------------+
| *Setter* | set_can_sleep(value) |
+-----------+----------------------+
| *Getter* | is_able_to_sleep() |
+-----------+----------------------+
If ``true``, the body can enter sleep mode when there is no movement. See :ref:`sleeping<class_RigidBody2D_property_sleeping>`.
\ **Note:** A RigidBody2D will never enter sleep mode automatically if its :ref:`mode<class_RigidBody2D_property_mode>` is :ref:`MODE_CHARACTER<class_RigidBody2D_constant_MODE_CHARACTER>`. It can still be put to sleep manually by setting its :ref:`sleeping<class_RigidBody2D_property_sleeping>` property to ``true``.
----
.. _class_RigidBody2D_property_contact_monitor:
- :ref:`bool<class_bool>` **contact_monitor**
+-----------+------------------------------+
| *Default* | ``false`` |
+-----------+------------------------------+
| *Setter* | set_contact_monitor(value) |
+-----------+------------------------------+
| *Getter* | is_contact_monitor_enabled() |
+-----------+------------------------------+
Si es ``true``, el cuerpo emitirá señales cuando colisione con otro RigidBody2D. Véase tambien :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>`.
----
.. _class_RigidBody2D_property_contacts_reported:
- :ref:`int<class_int>` **contacts_reported**
+-----------+----------------------------------+
| *Default* | ``0`` |
+-----------+----------------------------------+
| *Setter* | set_max_contacts_reported(value) |
+-----------+----------------------------------+
| *Getter* | get_max_contacts_reported() |
+-----------+----------------------------------+
The maximum number of contacts that will be recorded. Requires :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` to be set to ``true``.
\ **Note:** The number of contacts is different from the number of collisions. Collisions between parallel edges will result in two contacts (one at each end).
----
.. _class_RigidBody2D_property_continuous_cd:
- :ref:`CCDMode<enum_RigidBody2D_CCDMode>` **continuous_cd**
+-----------+------------------------------------------------+
| *Default* | ``0`` |
+-----------+------------------------------------------------+
| *Setter* | set_continuous_collision_detection_mode(value) |
+-----------+------------------------------------------------+
| *Getter* | get_continuous_collision_detection_mode() |
+-----------+------------------------------------------------+
Modo de detección de colisiones continua.
La detección de colisiones continua intenta predecir dónde colisionará un cuerpo en movimiento en lugar de moverlo y corregir su movimiento después de la colisión. La detección continua es más lenta, pero más precisa y desacierta menos colisiones con objetos pequeños y en rápido movimiento. Métodos para raycasting y shapecasting están disponibles. Véase :ref:`CCDMode<enum_RigidBody2D_CCDMode>` para más detalles.
----
.. _class_RigidBody2D_property_custom_integrator:
- :ref:`bool<class_bool>` **custom_integrator**
+-----------+----------------------------------+
| *Default* | ``false`` |
+-----------+----------------------------------+
| *Setter* | set_use_custom_integrator(value) |
+-----------+----------------------------------+
| *Getter* | is_using_custom_integrator() |
+-----------+----------------------------------+
Si es ``true``, la integración para fuerzas internas está desabilitada para este cuerpo. Aparte de reaccionar a colisiones, el cuerpo sólo se moverá por la función :ref:`_integrate_forces<class_RigidBody2D_method__integrate_forces>`.
----
.. _class_RigidBody2D_property_friction:
- :ref:`float<class_float>` **friction**
+----------+---------------------+
| *Setter* | set_friction(value) |
+----------+---------------------+
| *Getter* | get_friction() |
+----------+---------------------+
The body's friction. Values range from ``0`` (frictionless) to ``1`` (maximum friction).
Deprecated, use :ref:`PhysicsMaterial.friction<class_PhysicsMaterial_property_friction>` instead via :ref:`physics_material_override<class_RigidBody2D_property_physics_material_override>`.
----
.. _class_RigidBody2D_property_gravity_scale:
- :ref:`float<class_float>` **gravity_scale**
+-----------+--------------------------+
| *Default* | ``1.0`` |
+-----------+--------------------------+
| *Setter* | set_gravity_scale(value) |
+-----------+--------------------------+
| *Getter* | get_gravity_scale() |
+-----------+--------------------------+
Multiplica la gravedad aplicada al cuerpo. La gravedad del cuerpo se calcula a partir del valor **Gravedad por defecto** en **Proyecto > Configuración del proyecto > Física > 2d** y/o cualquier vector de gravedad adicional aplicado por :ref:`Area2D<class_Area2D>`\ s.
----
.. _class_RigidBody2D_property_inertia:
- :ref:`float<class_float>` **inertia**
+----------+--------------------+
| *Setter* | set_inertia(value) |
+----------+--------------------+
| *Getter* | get_inertia() |
+----------+--------------------+
El momento de inercia del cuerpo. Es como la masa, pero para la rotación: determina la cantidad de torsión que se necesita para girar el cuerpo. El momento de inercia suele calcularse automáticamente a partir de la masa y las formas, pero esta función permite establecer un valor personalizado. Establezca 0 inercia para volver a calcularlo automáticamente.
----
.. _class_RigidBody2D_property_linear_damp:
- :ref:`float<class_float>` **linear_damp**
+-----------+------------------------+
| *Default* | ``-1.0`` |
+-----------+------------------------+
| *Setter* | set_linear_damp(value) |
+-----------+------------------------+
| *Getter* | get_linear_damp() |
+-----------+------------------------+
Damps the body's :ref:`linear_velocity<class_RigidBody2D_property_linear_velocity>`. If ``-1``, the body will use the **Default Linear Damp** in **Project > Project Settings > Physics > 2d**.
See :ref:`ProjectSettings.physics/2d/default_linear_damp<class_ProjectSettings_property_physics/2d/default_linear_damp>` for more details about damping.
----
.. _class_RigidBody2D_property_linear_velocity:
- :ref:`Vector2<class_Vector2>` **linear_velocity**
+-----------+----------------------------+
| *Default* | ``Vector2( 0, 0 )`` |
+-----------+----------------------------+
| *Setter* | set_linear_velocity(value) |
+-----------+----------------------------+
| *Getter* | get_linear_velocity() |
+-----------+----------------------------+
The body's linear velocity in pixels per second. Can be used sporadically, but **don't set this every frame**, because physics may run in another thread and runs at a different granularity. Use :ref:`_integrate_forces<class_RigidBody2D_method__integrate_forces>` as your process loop for precise control of the body state.
----
.. _class_RigidBody2D_property_mass:
- :ref:`float<class_float>` **mass**
+-----------+-----------------+
| *Default* | ``1.0`` |
+-----------+-----------------+
| *Setter* | set_mass(value) |
+-----------+-----------------+
| *Getter* | get_mass() |
+-----------+-----------------+
La masa del cuerpo.
----
.. _class_RigidBody2D_property_mode:
- :ref:`Mode<enum_RigidBody2D_Mode>` **mode**
+-----------+-----------------+
| *Default* | ``0`` |
+-----------+-----------------+
| *Setter* | set_mode(value) |
+-----------+-----------------+
| *Getter* | get_mode() |
+-----------+-----------------+
El modo del cuerpo. Vea :ref:`Mode<enum_RigidBody2D_Mode>` para los posibles valores.
----
.. _class_RigidBody2D_property_physics_material_override:
- :ref:`PhysicsMaterial<class_PhysicsMaterial>` **physics_material_override**
+----------+--------------------------------------+
| *Setter* | set_physics_material_override(value) |
+----------+--------------------------------------+
| *Getter* | get_physics_material_override() |
+----------+--------------------------------------+
El material de la física se sobreescribe para el cuerpo.
Si se asigna un material a esta propiedad, se utilizará en lugar de cualquier otro material de física, como por ejemplo uno heredado.
----
.. _class_RigidBody2D_property_sleeping:
- :ref:`bool<class_bool>` **sleeping**
+-----------+---------------------+
| *Default* | ``false`` |
+-----------+---------------------+
| *Setter* | set_sleeping(value) |
+-----------+---------------------+
| *Getter* | is_sleeping() |
+-----------+---------------------+
Si ``true``, el cuerpo no se moverá y no calculará fuerzas hasta que sea despertado por otro cuerpo a través de, por ejemplo, una colisión, o utilizando los métodos :ref:`apply_impulse<class_RigidBody2D_method_apply_impulse>` o :ref:`add_force<class_RigidBody2D_method_add_force>`.
----
.. _class_RigidBody2D_property_weight:
- :ref:`float<class_float>` **weight**
+-----------+-------------------+
| *Default* | ``9.8`` |
+-----------+-------------------+
| *Setter* | set_weight(value) |
+-----------+-------------------+
| *Getter* | get_weight() |
+-----------+-------------------+
El peso del cuerpo basado en su masa y el valor **Gravedad por defecto** en **Proyecto > Configuración del proyecto > Física > 2d**.
Descripciones de Métodos
------------------------------------------------
.. _class_RigidBody2D_method__integrate_forces:
- void **_integrate_forces** **(** :ref:`Physics2DDirectBodyState<class_Physics2DDirectBodyState>` state **)** |virtual|
Permite leer y modificar con seguridad el estado de simulación del objeto. Utilízalo en lugar del :ref:`Node._physics_process<class_Node_method__physics_process>` si necesitas cambiar directamente la ``position`` del cuerpo o otras propiedades físicas. Por defecto, funciona además del comportamiento físico habitual, pero :ref:`custom_integrator<class_RigidBody2D_property_custom_integrator>` te permite desactivar el comportamiento por defecto y escribir la integración de fuerza personalizada para un cuerpo.
----
.. _class_RigidBody2D_method_add_central_force:
- void **add_central_force** **(** :ref:`Vector2<class_Vector2>` force **)**
Añade una fuerza direccional constante sin afectar a la rotación.
----
.. _class_RigidBody2D_method_add_force:
- void **add_force** **(** :ref:`Vector2<class_Vector2>` offset, :ref:`Vector2<class_Vector2>` force **)**
Añade una fuerza posicionada al cuerpo. Tanto la fuerza como el desplazamiento del origen del cuerpo están en coordenadas globales.
----
.. _class_RigidBody2D_method_add_torque:
- void **add_torque** **(** :ref:`float<class_float>` torque **)**
Añade una fuerza de rotación constante.
----
.. _class_RigidBody2D_method_apply_central_impulse:
- void **apply_central_impulse** **(** :ref:`Vector2<class_Vector2>` impulse **)**
Aplica un impulso direccional sin afectar a la rotación.
----
.. _class_RigidBody2D_method_apply_impulse:
- void **apply_impulse** **(** :ref:`Vector2<class_Vector2>` offset, :ref:`Vector2<class_Vector2>` impulse **)**
Aplica un impulso posicionado al cuerpo. ¡Un impulso es independiente del tiempo! Aplicar un impulso en cada cuadro resultaría en una fuerza dependiente del cuadro. Por esta razón, sólo debe utilizarse cuando se simulan impactos únicos (de lo contrario, utilice las funciones "_force"). La posición utiliza la rotación del sistema de coordenadas globales, pero está centrada en el origen del objeto.
----
.. _class_RigidBody2D_method_apply_torque_impulse:
- void **apply_torque_impulse** **(** :ref:`float<class_float>` torque **)**
Aplica un impulso de rotación al cuerpo.
----
.. _class_RigidBody2D_method_get_colliding_bodies:
- :ref:`Array<class_Array>` **get_colliding_bodies** **(** **)** |const|
Retorna una lista de los cuerpos que colisionan con éste. Requiere que :ref:`contact_monitor<class_RigidBody2D_property_contact_monitor>` sea ``true``, y que :ref:`contacts_reported<class_RigidBody2D_property_contacts_reported>` sea lo suficientemente alto para detectar todas las colisiones.
\ **Nota:** El resultado de esta prueba no es inmediato después de mover los objetos. Para un mejor rendimiento, la lista de superposiciones se actualiza una vez por cuadro y antes del paso de física. Considere la posibilidad de utilizar señales en su lugar.
----
.. _class_RigidBody2D_method_set_axis_velocity:
- void **set_axis_velocity** **(** :ref:`Vector2<class_Vector2>` axis_velocity **)**
Asigna la velocidad del cuerpo en el eje dado. La velocidad en el eje del vector será asignada como la longitud del vector. Esto es útil para comportamiento pertinente al salto.
----
.. _class_RigidBody2D_method_test_motion:
- :ref:`bool<class_bool>` **test_motion** **(** :ref:`Vector2<class_Vector2>` motion, :ref:`bool<class_bool>` infinite_inertia=true, :ref:`float<class_float>` margin=0.08, :ref:`Physics2DTestMotionResult<class_Physics2DTestMotionResult>` result=null **)**
Returns ``true`` if a collision would result from moving in the given vector. ``margin`` increases the size of the shapes involved in the collision detection, and ``result`` is an object of type :ref:`Physics2DTestMotionResult<class_Physics2DTestMotionResult>`, which contains additional information about the collision (should there be one).
.. |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.)`