2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 10:08:05 +02:00
<class name= "PhysicsDirectBodyState2D" inherits= "Object" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 22:42:36 +02:00
<brief_description >
2023-04-28 22:59:03 +02:00
Provides direct access to a physics body in the [PhysicsServer2D].
2017-09-12 22:42:36 +02:00
</brief_description>
<description >
2023-04-28 22:59:03 +02:00
Provides direct access to a physics body in the [PhysicsServer2D], allowing safe changes to physics properties. This object is passed via the direct state callback of [RigidBody2D], and is intended for changing the direct state of that body. See [method RigidBody2D._integrate_forces].
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
2021-11-15 10:43:07 +01:00
<link title= "Physics introduction" > $DOCS_URL/tutorials/physics/physics_introduction.html</link>
<link title= "Ray-casting" > $DOCS_URL/tutorials/physics/ray-casting.html</link>
2017-09-12 22:42:36 +02:00
</tutorials>
<methods >
2021-12-08 02:09:54 +01:00
<method name= "add_constant_central_force" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "force" type= "Vector2" default= "Vector2(0, 0)" />
2018-07-26 11:56:21 +02:00
<description >
2021-12-08 02:09:54 +01:00
Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with [code]constant_force = Vector2(0, 0)[/code].
This is equivalent to using [method add_constant_force] at the body's center of mass.
2018-07-26 11:56:21 +02:00
</description>
</method>
2021-12-08 02:09:54 +01:00
<method name= "add_constant_force" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "force" type= "Vector2" />
<param index= "1" name= "position" type= "Vector2" default= "Vector2(0, 0)" />
2018-07-26 11:56:21 +02:00
<description >
2021-12-08 02:09:54 +01:00
Adds a constant positioned force to the body that keeps being applied over time until cleared with [code]constant_force = Vector2(0, 0)[/code].
2022-08-11 19:52:19 +02:00
[param position] is the offset from the body origin in global coordinates.
2018-07-26 11:56:21 +02:00
</description>
</method>
2021-12-08 02:09:54 +01:00
<method name= "add_constant_torque" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "torque" type= "float" />
2018-07-26 11:56:21 +02:00
<description >
2021-12-08 02:09:54 +01:00
Adds a constant rotational force without affecting position that keeps being applied over time until cleared with [code]constant_torque = 0[/code].
</description>
</method>
<method name= "apply_central_force" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "force" type= "Vector2" default= "Vector2(0, 0)" />
2021-12-08 02:09:54 +01:00
<description >
Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
This is equivalent to using [method apply_force] at the body's center of mass.
2018-07-26 11:56:21 +02:00
</description>
</method>
<method name= "apply_central_impulse" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "impulse" type= "Vector2" />
2018-07-26 11:56:21 +02:00
<description >
2019-03-26 05:20:52 +01:00
Applies a directional impulse without affecting rotation.
2021-12-08 02:09:54 +01:00
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
This is equivalent to using [method apply_impulse] at the body's center of mass.
</description>
</method>
<method name= "apply_force" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "force" type= "Vector2" />
<param index= "1" name= "position" type= "Vector2" default= "Vector2(0, 0)" />
2021-12-08 02:09:54 +01:00
<description >
Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
2022-08-11 19:52:19 +02:00
[param position] is the offset from the body origin in global coordinates.
2018-07-26 11:56:21 +02:00
</description>
</method>
<method name= "apply_impulse" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "impulse" type= "Vector2" />
<param index= "1" name= "position" type= "Vector2" default= "Vector2(0, 0)" />
2018-07-26 11:56:21 +02:00
<description >
2021-12-08 02:09:54 +01:00
Applies a positioned impulse to the body.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
2022-08-11 19:52:19 +02:00
[param position] is the offset from the body origin in global coordinates.
2021-12-08 02:09:54 +01:00
</description>
</method>
<method name= "apply_torque" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "torque" type= "float" />
2021-12-08 02:09:54 +01:00
<description >
Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
2022-11-06 16:14:04 +01:00
[b]Note:[/b] [member inverse_inertia] is required for this to work. To have [member inverse_inertia], an active [CollisionShape2D] must be a child of the node, or you can manually set [member inverse_inertia].
2018-07-26 11:56:21 +02:00
</description>
</method>
<method name= "apply_torque_impulse" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "impulse" type= "float" />
2018-07-26 11:56:21 +02:00
<description >
2021-12-08 02:09:54 +01:00
Applies a rotational impulse to the body without affecting the position.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
2022-11-06 16:14:04 +01:00
[b]Note:[/b] [member inverse_inertia] is required for this to work. To have [member inverse_inertia], an active [CollisionShape2D] must be a child of the node, or you can manually set [member inverse_inertia].
2021-12-08 02:09:54 +01:00
</description>
</method>
<method name= "get_constant_force" qualifiers= "const" >
<return type= "Vector2" />
<description >
Returns the body's total constant positional forces applied during each physics update.
See [method add_constant_force] and [method add_constant_central_force].
</description>
</method>
<method name= "get_constant_torque" qualifiers= "const" >
<return type= "float" />
<description >
Returns the body's total constant rotational forces applied during each physics update.
See [method add_constant_torque].
2018-07-26 11:56:21 +02:00
</description>
</method>
2017-09-12 22:42:36 +02:00
<method name= "get_contact_collider" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "RID" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the collider's [RID].
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_contact_collider_id" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the collider's object id.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_contact_collider_object" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Object" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it).
2017-09-12 22:42:36 +02:00
</description>
</method>
2017-09-10 15:37:49 +02:00
<method name= "get_contact_collider_position" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2023-04-15 14:29:01 +02:00
Returns the position of the contact point on the collider in the global coordinate system.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_contact_collider_shape" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the collider's shape index.
2017-09-12 22:42:36 +02:00
</description>
</method>
2017-09-10 15:37:49 +02:00
<method name= "get_contact_collider_velocity_at_position" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2023-04-13 21:45:37 +02:00
Returns the velocity vector at the collider's contact point.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_contact_count" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-06-22 01:04:47 +02:00
Returns the number of contacts this body has with other bodies.
2022-08-25 19:35:52 +02:00
[b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody2D.contact_monitor].
2017-09-12 22:42:36 +02:00
</description>
</method>
2023-01-10 23:28:02 +01:00
<method name= "get_contact_impulse" qualifiers= "const" >
<return type= "Vector2" />
<param index= "0" name= "contact_idx" type= "int" />
<description >
Returns the impulse created by the contact.
</description>
</method>
2017-09-12 22:42:36 +02:00
<method name= "get_contact_local_normal" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the local normal at the contact point.
2017-09-12 22:42:36 +02:00
</description>
</method>
2017-09-10 15:37:49 +02:00
<method name= "get_contact_local_position" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2023-04-15 14:29:01 +02:00
Returns the position of the contact point on the body in the global coordinate system.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_contact_local_shape" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "contact_idx" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the local shape index of the collision.
2017-09-12 22:42:36 +02:00
</description>
</method>
2023-04-13 21:45:37 +02:00
<method name= "get_contact_local_velocity_at_position" qualifiers= "const" >
<return type= "Vector2" />
<param index= "0" name= "contact_idx" type= "int" />
<description >
Returns the velocity vector at the body's contact point.
</description>
</method>
2017-09-12 22:42:36 +02:00
<method name= "get_space_state" >
2021-07-30 15:28:05 +02:00
<return type= "PhysicsDirectSpaceState2D" />
2017-09-12 22:42:36 +02:00
<description >
2019-03-26 05:20:52 +01:00
Returns the current state of the space, useful for queries.
2017-09-12 22:42:36 +02:00
</description>
</method>
2021-08-09 21:14:24 +02:00
<method name= "get_velocity_at_local_position" qualifiers= "const" >
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "local_position" type= "Vector2" />
2021-08-09 21:14:24 +02:00
<description >
Returns the body's velocity at the given relative position, including both translation and rotation.
</description>
</method>
2017-09-12 22:42:36 +02:00
<method name= "integrate_forces" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2017-09-12 22:42:36 +02:00
<description >
2023-08-02 14:57:15 +02:00
Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
2017-09-12 22:42:36 +02:00
</description>
</method>
2021-12-08 02:09:54 +01:00
<method name= "set_constant_force" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "force" type= "Vector2" />
2021-12-08 02:09:54 +01:00
<description >
Sets the body's total constant positional forces applied during each physics update.
See [method add_constant_force] and [method add_constant_central_force].
</description>
</method>
<method name= "set_constant_torque" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "torque" type= "float" />
2021-12-08 02:09:54 +01:00
<description >
Sets the body's total constant rotational forces applied during each physics update.
See [method add_constant_torque].
</description>
</method>
2017-09-12 22:42:36 +02:00
</methods>
2018-01-11 23:38:35 +01:00
<members >
2022-11-09 08:59:49 +01:00
<member name= "angular_velocity" type= "float" setter= "set_angular_velocity" getter= "get_angular_velocity" >
2021-12-11 17:38:55 +01:00
The body's rotational velocity in [i]radians[/i] per second.
2018-01-11 23:38:35 +01:00
</member>
2022-11-09 08:59:49 +01:00
<member name= "center_of_mass" type= "Vector2" setter= "" getter= "get_center_of_mass" >
2021-10-22 20:56:00 +02:00
The body's center of mass position relative to the body's center in the global coordinate system.
</member>
2022-11-09 08:59:49 +01:00
<member name= "center_of_mass_local" type= "Vector2" setter= "" getter= "get_center_of_mass_local" >
2021-10-22 20:56:00 +02:00
The body's center of mass position in the body's local coordinate system.
2021-06-11 02:37:19 +02:00
</member>
2022-11-09 08:59:49 +01:00
<member name= "inverse_inertia" type= "float" setter= "" getter= "get_inverse_inertia" >
2018-01-11 23:38:35 +01:00
The inverse of the inertia of the body.
</member>
2022-11-09 08:59:49 +01:00
<member name= "inverse_mass" type= "float" setter= "" getter= "get_inverse_mass" >
2018-01-11 23:38:35 +01:00
The inverse of the mass of the body.
</member>
2022-11-09 08:59:49 +01:00
<member name= "linear_velocity" type= "Vector2" setter= "set_linear_velocity" getter= "get_linear_velocity" >
2021-12-11 17:38:55 +01:00
The body's linear velocity in pixels per second.
2018-01-11 23:38:35 +01:00
</member>
2022-11-09 08:59:49 +01:00
<member name= "sleeping" type= "bool" setter= "set_sleep_state" getter= "is_sleeping" >
2019-03-26 05:20:52 +01:00
If [code]true[/code], this body is currently sleeping (not active).
2018-01-11 23:38:35 +01:00
</member>
2022-11-09 08:59:49 +01:00
<member name= "step" type= "float" setter= "" getter= "get_step" >
2018-01-11 23:38:35 +01:00
The timestep (delta) used for the simulation.
</member>
2022-11-09 08:59:49 +01:00
<member name= "total_angular_damp" type= "float" setter= "" getter= "get_total_angular_damp" >
2018-01-11 23:38:35 +01:00
The rate at which the body stops rotating, if there are not any other forces moving it.
</member>
2022-11-09 08:59:49 +01:00
<member name= "total_gravity" type= "Vector2" setter= "" getter= "get_total_gravity" >
2018-01-11 23:38:35 +01:00
The total gravity vector being currently applied to this body.
</member>
2022-11-09 08:59:49 +01:00
<member name= "total_linear_damp" type= "float" setter= "" getter= "get_total_linear_damp" >
2018-01-11 23:38:35 +01:00
The rate at which the body stops moving, if there are not any other forces moving it.
</member>
2022-11-09 08:59:49 +01:00
<member name= "transform" type= "Transform2D" setter= "set_transform" getter= "get_transform" >
2019-03-26 05:20:52 +01:00
The body's transformation matrix.
2018-01-11 23:38:35 +01:00
</member>
</members>
2017-09-12 22:42:36 +02:00
</class>