Debian Codegraph @

doc/classes/PhysicsDirectBodyState2D.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="PhysicsDirectBodyState2D" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Provides direct access to a physics body in the [PhysicsServer2D].
5 </brief_description>
6 <description>
7 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].
8 </description>
9 <tutorials>
10 <link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
11 <link title="Ray-casting">$DOCS_URL/tutorials/physics/ray-casting.html</link>
12 </tutorials>
13 <methods>
14 <method name="add_constant_central_force">
15 <return type="void" />
16 <param index="0" name="force" type="Vector2" default="Vector2(0, 0)" />
17 <description>
18 Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with [code]constant_force = Vector2(0, 0)[/code].
19 This is equivalent to using [method add_constant_force] at the body's center of mass.
20 </description>
21 </method>
22 <method name="add_constant_force">
23 <return type="void" />
24 <param index="0" name="force" type="Vector2" />
25 <param index="1" name="position" type="Vector2" default="Vector2(0, 0)" />
26 <description>
27 Adds a constant positioned force to the body that keeps being applied over time until cleared with [code]constant_force = Vector2(0, 0)[/code].
28 [param position] is the offset from the body origin in global coordinates.
29 </description>
30 </method>
31 <method name="add_constant_torque">
32 <return type="void" />
33 <param index="0" name="torque" type="float" />
34 <description>
35 Adds a constant rotational force without affecting position that keeps being applied over time until cleared with [code]constant_torque = 0[/code].
36 </description>
37 </method>
38 <method name="apply_central_force">
39 <return type="void" />
40 <param index="0" name="force" type="Vector2" default="Vector2(0, 0)" />
41 <description>
42 Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
43 This is equivalent to using [method apply_force] at the body's center of mass.
44 </description>
45 </method>
46 <method name="apply_central_impulse">
47 <return type="void" />
48 <param index="0" name="impulse" type="Vector2" />
49 <description>
50 Applies a directional impulse without affecting rotation.
51 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).
52 This is equivalent to using [method apply_impulse] at the body's center of mass.
53 </description>
54 </method>
55 <method name="apply_force">
56 <return type="void" />
57 <param index="0" name="force" type="Vector2" />
58 <param index="1" name="position" type="Vector2" default="Vector2(0, 0)" />
59 <description>
60 Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
61 [param position] is the offset from the body origin in global coordinates.
62 </description>
63 </method>
64 <method name="apply_impulse">
65 <return type="void" />
66 <param index="0" name="impulse" type="Vector2" />
67 <param index="1" name="position" type="Vector2" default="Vector2(0, 0)" />
68 <description>
69 Applies a positioned impulse to the body.
70 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).
71 [param position] is the offset from the body origin in global coordinates.
72 </description>
73 </method>
74 <method name="apply_torque">
75 <return type="void" />
76 <param index="0" name="torque" type="float" />
77 <description>
78 Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
79 [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].
80 </description>
81 </method>
82 <method name="apply_torque_impulse">
83 <return type="void" />
84 <param index="0" name="impulse" type="float" />
85 <description>
86 Applies a rotational impulse to the body without affecting the position.
87 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).
88 [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].
89 </description>
90 </method>
91 <method name="get_constant_force" qualifiers="const">
92 <return type="Vector2" />
93 <description>
94 Returns the body's total constant positional forces applied during each physics update.
95 See [method add_constant_force] and [method add_constant_central_force].
96 </description>
97 </method>
98 <method name="get_constant_torque" qualifiers="const">
99 <return type="float" />
100 <description>
101 Returns the body's total constant rotational forces applied during each physics update.
102 See [method add_constant_torque].
103 </description>
104 </method>
105 <method name="get_contact_collider" qualifiers="const">
106 <return type="RID" />
107 <param index="0" name="contact_idx" type="int" />
108 <description>
109 Returns the collider's [RID].
110 </description>
111 </method>
112 <method name="get_contact_collider_id" qualifiers="const">
113 <return type="int" />
114 <param index="0" name="contact_idx" type="int" />
115 <description>
116 Returns the collider's object id.
117 </description>
118 </method>
119 <method name="get_contact_collider_object" qualifiers="const">
120 <return type="Object" />
121 <param index="0" name="contact_idx" type="int" />
122 <description>
123 Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it).
124 </description>
125 </method>
126 <method name="get_contact_collider_position" qualifiers="const">
127 <return type="Vector2" />
128 <param index="0" name="contact_idx" type="int" />
129 <description>
130 Returns the position of the contact point on the collider in the global coordinate system.
131 </description>
132 </method>
133 <method name="get_contact_collider_shape" qualifiers="const">
134 <return type="int" />
135 <param index="0" name="contact_idx" type="int" />
136 <description>
137 Returns the collider's shape index.
138 </description>
139 </method>
140 <method name="get_contact_collider_velocity_at_position" qualifiers="const">
141 <return type="Vector2" />
142 <param index="0" name="contact_idx" type="int" />
143 <description>
144 Returns the velocity vector at the collider's contact point.
145 </description>
146 </method>
147 <method name="get_contact_count" qualifiers="const">
148 <return type="int" />
149 <description>
150 Returns the number of contacts this body has with other bodies.
151 [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody2D.contact_monitor].
152 </description>
153 </method>
154 <method name="get_contact_impulse" qualifiers="const">
155 <return type="Vector2" />
156 <param index="0" name="contact_idx" type="int" />
157 <description>
158 Returns the impulse created by the contact.
159 </description>
160 </method>
161 <method name="get_contact_local_normal" qualifiers="const">
162 <return type="Vector2" />
163 <param index="0" name="contact_idx" type="int" />
164 <description>
165 Returns the local normal at the contact point.
166 </description>
167 </method>
168 <method name="get_contact_local_position" qualifiers="const">
169 <return type="Vector2" />
170 <param index="0" name="contact_idx" type="int" />
171 <description>
172 Returns the position of the contact point on the body in the global coordinate system.
173 </description>
174 </method>
175 <method name="get_contact_local_shape" qualifiers="const">
176 <return type="int" />
177 <param index="0" name="contact_idx" type="int" />
178 <description>
179 Returns the local shape index of the collision.
180 </description>
181 </method>
182 <method name="get_contact_local_velocity_at_position" qualifiers="const">
183 <return type="Vector2" />
184 <param index="0" name="contact_idx" type="int" />
185 <description>
186 Returns the velocity vector at the body's contact point.
187 </description>
188 </method>
189 <method name="get_space_state">
190 <return type="PhysicsDirectSpaceState2D" />
191 <description>
192 Returns the current state of the space, useful for queries.
193 </description>
194 </method>
195 <method name="get_velocity_at_local_position" qualifiers="const">
196 <return type="Vector2" />
197 <param index="0" name="local_position" type="Vector2" />
198 <description>
199 Returns the body's velocity at the given relative position, including both translation and rotation.
200 </description>
201 </method>
202 <method name="integrate_forces">
203 <return type="void" />
204 <description>
205 Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
206 </description>
207 </method>
208 <method name="set_constant_force">
209 <return type="void" />
210 <param index="0" name="force" type="Vector2" />
211 <description>
212 Sets the body's total constant positional forces applied during each physics update.
213 See [method add_constant_force] and [method add_constant_central_force].
214 </description>
215 </method>
216 <method name="set_constant_torque">
217 <return type="void" />
218 <param index="0" name="torque" type="float" />
219 <description>
220 Sets the body's total constant rotational forces applied during each physics update.
221 See [method add_constant_torque].
222 </description>
223 </method>
224 </methods>
225 <members>
226 <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity">
227 The body's rotational velocity in [i]radians[/i] per second.
228 </member>
229 <member name="center_of_mass" type="Vector2" setter="" getter="get_center_of_mass">
230 The body's center of mass position relative to the body's center in the global coordinate system.
231 </member>
232 <member name="center_of_mass_local" type="Vector2" setter="" getter="get_center_of_mass_local">
233 The body's center of mass position in the body's local coordinate system.
234 </member>
235 <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer">
236 The body's collision layer.
237 </member>
238 <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
239 The body's collision mask.
240 </member>
241 <member name="inverse_inertia" type="float" setter="" getter="get_inverse_inertia">
242 The inverse of the inertia of the body.
243 </member>
244 <member name="inverse_mass" type="float" setter="" getter="get_inverse_mass">
245 The inverse of the mass of the body.
246 </member>
247 <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity">
248 The body's linear velocity in pixels per second.
249 </member>
250 <member name="sleeping" type="bool" setter="set_sleep_state" getter="is_sleeping">
251 If [code]true[/code], this body is currently sleeping (not active).
252 </member>
253 <member name="step" type="float" setter="" getter="get_step">
254 The timestep (delta) used for the simulation.
255 </member>
256 <member name="total_angular_damp" type="float" setter="" getter="get_total_angular_damp">
257 The rate at which the body stops rotating, if there are not any other forces moving it.
258 </member>
259 <member name="total_gravity" type="Vector2" setter="" getter="get_total_gravity">
260 The total gravity vector being currently applied to this body.
261 </member>
262 <member name="total_linear_damp" type="float" setter="" getter="get_total_linear_damp">
263 The rate at which the body stops moving, if there are not any other forces moving it.
264 </member>
265 <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
266 The body's transformation matrix.
267 </member>
268 </members>
269 </class>