RigidBody3D
- Game Development course
- Intermediate
- Lesson 65/83
- 4 min
Learn physics-based motion with RigidBody3D.
Physics Simulation with RigidBody3D
In Godot 3D, the RigidBody3D node is used for objects governed by physics rules like gravity, mass, and collisions. Its movement is computed by the physics engine rather than direct script transforms. To detect collisions, it must have a CollisionShape3D child node.
RigidBody3D body = new RigidBody3D();
body.Mass = 5.0f;Mass and Central Impulse
The Mass property of the RigidBody3D node determines the object's mass in kilograms. To toss or shove an object physically, force is applied via the ApplyCentralImpulse() method instead of mutating coordinates directly.
// Pushes object with an instantaneous physical impulse:
// body.ApplyCentralImpulse(new Vector3(0, 10, 0));Practice Configure Physics Mass
Assign 5.0f to body.Mass and print it with GD.Print("Kutle: " + body.Mass);.
Starter code
using System;
public class RigidBody3D
{
public float Mass { get; set; } = 1.0f;
public bool Freeze { get; set; } = false;
}
public static class GD
{
public static void Print(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
RigidBody3D body = new RigidBody3D();
// Kutle degerini 5.0f yap ve ekrana yazdir
}
}Sample solution
using System;
public class RigidBody3D
{
public float Mass { get; set; } = 1.0f;
public bool Freeze { get; set; } = false;
}
public static class GD
{
public static void Print(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
RigidBody3D body = new RigidBody3D();
body.Mass = 5.0f;
GD.Print("Kutle: " + body.Mass);
}
}Expected output
Kutle: 5
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which child node is required for a RigidBody3D node to physically collide with other objects in Godot 3D?
- CollisionShape3D Correct answer
- Camera3D
- DirectionalLight3D
- MeshInstance3D
Explanation: A CollisionShape3D node is required for the physics engine to calculate the object's collision boundaries.
2 Assign Mass Value
body.____ = 10.0f;
body.Mass = 10.0f;
Explanation: The Mass property is used to define the mass of a RigidBody3D object.
3 Godot Physics Terminology
| Term | Meaning |
|---|---|
RigidBody3D |
Dynamic 3D node moving with physics |
CollisionShape3D |
Node defining collision geometry |
Mass |
Physical mass value of the object |
ApplyCentralImpulse |
Applies impulse to object center |