summaryrefslogtreecommitdiff
path: root/doc/classes
diff options
context:
space:
mode:
author[Error_27] <error27dev@gmail.com>2023-02-04 11:53:01 -0500
committer[Error_27] <error27dev@gmail.com>2023-02-10 20:43:25 -0500
commit417bd5b27fd5b2d6c0efc3db6b740fac343bc019 (patch)
tree78be5667685ee671b74dfec596129f805aefc31e /doc/classes
parent0b1d516f67a3b2b7dd158b923559f192ec103a85 (diff)
Add how to retrieve RigidBody2D and RigidBody3D autocomputed inertia
Diffstat (limited to 'doc/classes')
-rw-r--r--doc/classes/RigidBody2D.xml22
-rw-r--r--doc/classes/RigidBody3D.xml22
2 files changed, 44 insertions, 0 deletions
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index 6e3535f14a..937d0910ec 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -176,6 +176,28 @@
<member name="inertia" type="float" setter="set_inertia" getter="get_inertia" default="0.0">
The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
If set to [code]0[/code], inertia is automatically computed (default value).
+ [b]Note:[/b] This value does not change when inertia is automatically computed. Use [PhysicsServer2D] to get the computed inertia.
+ [codeblocks]
+ [gdscript]
+ @onready var ball = $Ball
+
+ func get_ball_inertia():
+ return 1.0 / PhysicsServer2D.body_get_direct_state(ball.get_rid()).inverse_inertia
+ [/gdscript]
+ [csharp]
+ private RigidBody2D _ball;
+
+ public override void _Ready()
+ {
+ _ball = GetNode&lt;RigidBody2D&gt;("Ball");
+ }
+
+ private float GetBallInertia()
+ {
+ return 1.0f / PhysicsServer2D.BodyGetDirectState(_ball.GetRid()).InverseInertia;
+ }
+ [/csharp]
+ [/codeblocks]
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.0">
Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value.
diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml
index 148cdf96ee..a066254b4f 100644
--- a/doc/classes/RigidBody3D.xml
+++ b/doc/classes/RigidBody3D.xml
@@ -183,6 +183,28 @@
<member name="inertia" type="Vector3" setter="set_inertia" getter="get_inertia" default="Vector3(0, 0, 0)">
The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body on each axis. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
If set to [code]Vector3.ZERO[/code], inertia is automatically computed (default value).
+ [b]Note:[/b] This value does not change when inertia is automatically computed. Use [PhysicsServer3D] to get the computed inertia.
+ [codeblocks]
+ [gdscript]
+ @onready var ball = $Ball
+
+ func get_ball_inertia():
+ return PhysicsServer3D.body_get_direct_state(ball.get_rid()).inverse_inertia.inverse()
+ [/gdscript]
+ [csharp]
+ private RigidBody3D _ball;
+
+ public override void _Ready()
+ {
+ _ball = GetNode&lt;RigidBody3D&gt;("Ball");
+ }
+
+ private Vector3 GetBallInertia()
+ {
+ return PhysicsServer3D.BodyGetDirectState(_ball.GetRid()).InverseInertia.Inverse();
+ }
+ [/csharp]
+ [/codeblocks]
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.0">
Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value.