Introduction to 3D in Godot
Godot Engine provides a comprehensive 3D system built around nodes that inherit fromNode3D, the base class for all spatial objects. Understanding the 3D coordinate system, transformations, and scene organization is essential for creating 3D games and applications.
The 3D Coordinate System
Godot uses a right-handed coordinate system where:- X axis: Points to the right (red)
- Y axis: Points upward (green)
- Z axis: Points backward (blue)
In Godot, the forward direction is -Z (
Vector3.FORWARD), which means objects face in the negative Z direction by default.Coordinate Spaces
Godot distinguishes between different coordinate spaces:Local Space
Coordinates relative to the node’s own transform. Also called “object-local coordinate system.”
Parent Space
Coordinates relative to the parent node’s transform (unless
top_level is true).Global Space
Coordinates relative to the world origin, independent of parent transforms.
Node3D: The Base Class
Node3D is the fundamental building block for all 3D nodes in Godot. Every 3D object inherits from this class.
In Godot 3 and older versions,
Node3D was called Spatial.Key Properties
Transform Properties
| Property | Type | Description |
|---|---|---|
position | Vector3 | Position in parent space (doc/classes/Node3D.xml:320) |
rotation | Vector3 | Euler angles in radians (doc/classes/Node3D.xml:327) |
rotation_degrees | Vector3 | Rotation in degrees (doc/classes/Node3D.xml:335) |
scale | Vector3 | Scale in local space (doc/classes/Node3D.xml:345) |
transform | Transform3D | Complete local transformation (doc/classes/Node3D.xml:353) |
global_transform | Transform3D | Transformation in global space (doc/classes/Node3D.xml:316) |
basis | Basis | Rotation, scale, and shear matrix (doc/classes/Node3D.xml:293) |
Common Transformation Methods
Translation
Rotation
Look At
Make a node face a target position:look_at() method at doc/classes/Node3D.xml:127
Coordinate Conversion
3D Scene Structure
A typical 3D scene hierarchy follows this pattern:Visibility Control
Advanced Transform Features
Top Level Nodes
top_level is true, the node ignores parent transformations (doc/classes/Node3D.xml:350).
Orthonormalization
Transform Notifications
Getting Parent Relationships
Best Practices
Use Radians for Rotation
Use Radians for Rotation
All rotation methods expect radians. Always use
deg_to_rad() when working with degrees:Avoid Non-Uniform Scaling
Avoid Non-Uniform Scaling
Non-uniform scaling can cause issues with physics and some nodes:
Use translate_object_local for Movement
Use translate_object_local for Movement
For local movement (like moving forward), use
translate_object_local():Force Transform Updates Carefully
Force Transform Updates Carefully
Only call
force_update_transform() when absolutely necessary (like in physics operations), as it has performance costs:Common Patterns
Moving an Object Forward
Orbiting Around a Point
Smooth Following
Related Topics
Meshes and Materials
Learn about rendering 3D geometry
Lighting
Explore 3D lighting techniques
Physics
Understand 3D physics simulation
Camera
Master camera controls and perspectives
Resources
- Introduction to 3D
- Godot 3D Demos
- Node3D Class Reference: doc/classes/Node3D.xml