Node3D
Inherited By:AudioListener3D,AudioStreamPlayer3D,BoneAttachment3D,Camera3D,CollisionObject3D,CollisionPolygon3D,CollisionShape3D,GridMap,ImporterMeshInstance3D,Joint3D,LightmapProbe,Marker3D,NavigationLink3D,NavigationObstacle3D,NavigationRegion3D,OpenXRCompositionLayer,OpenXRHand,Path3D,PathFollow3D,RayCast3D,RemoteTransform3D,ShapeCast3D,Skeleton3D,SkeletonModifier3D,SpringArm3D,SpringBoneCollision3D,VehicleWheel3D,VisualInstance3D,XRFaceModifier3D,XRNode3D,XROrigin3D
Most basic 3D game object, parent of all 3D-related nodes.
Description
Most basic 3D game object, with aTransform3D and visibility settings. All other 3D game objects inherit fromNode3D. UseNode3D as a parent node to move, scale, rotate and show/hide children in a 3D project.
Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless theNode3D object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on theNode3D's transform. The word local below refers to this coordinate system. The coordinate system that is attached to theNode3D object itself is referred to as object-local coordinate system.
Note: Unless otherwise specified, all methods that have angle parameters must have angles specified asradians. To convert degrees to radians, use@GlobalScope.deg_to_rad().
Note: Be aware that "Spatial" nodes are now called "Node3D" starting with Godot 4. Any Godot 3.x references to "Spatial" nodes refer to "Node3D" in Godot 4.
Tutorials
Properties
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Methods
add_gizmo(gizmo:Node3DGizmo) | |
global_rotate(axis:Vector3, angle:float) | |
global_scale(scale:Vector3) | |
global_translate(offset:Vector3) | |
hide() | |
look_at(target:Vector3, up:Vector3 = Vector3(0, 1, 0), use_model_front:bool = false) | |
look_at_from_position(position:Vector3, target:Vector3, up:Vector3 = Vector3(0, 1, 0), use_model_front:bool = false) | |
rotate_object_local(axis:Vector3, angle:float) | |
scale_object_local(scale:Vector3) | |
set_disable_scale(disable:bool) | |
set_ignore_transform_notification(enabled:bool) | |
set_notify_local_transform(enable:bool) | |
set_notify_transform(enable:bool) | |
set_subgizmo_selection(gizmo:Node3DGizmo, id:int, transform:Transform3D) | |
show() | |
translate_object_local(offset:Vector3) | |
Signals
visibility_changed()🔗
Emitted when node visibility changes.
Enumerations
enumRotationEditMode:🔗
RotationEditModeROTATION_EDIT_MODE_EULER =0
The rotation is edited usingVector3 Euler angles.
RotationEditModeROTATION_EDIT_MODE_QUATERNION =1
The rotation is edited using aQuaternion.
RotationEditModeROTATION_EDIT_MODE_BASIS =2
The rotation is edited using aBasis. In this mode,scale can't be edited separately.
Constants
NOTIFICATION_TRANSFORM_CHANGED =2000
🔗
Node3D nodes receive this notification when their global transform changes. This means that either the current or a parent node changed its transform.
In order forNOTIFICATION_TRANSFORM_CHANGED to work, users first need to ask for it, withset_notify_transform(). The notification is also sent if the node is in the editor context and it has at least one valid gizmo.
NOTIFICATION_ENTER_WORLD =41
🔗
Node3D nodes receive this notification when they are registered to newWorld3D resource.
NOTIFICATION_EXIT_WORLD =42
🔗
Node3D nodes receive this notification when they are unregistered from currentWorld3D resource.
NOTIFICATION_VISIBILITY_CHANGED =43
🔗
Node3D nodes receive this notification when their visibility changes.
NOTIFICATION_LOCAL_TRANSFORM_CHANGED =44
🔗
Node3D nodes receive this notification when their local transform changes. This is not received when the transform of a parent node is changed.
In order forNOTIFICATION_LOCAL_TRANSFORM_CHANGED to work, users first need to ask for it, withset_notify_local_transform().
Property Descriptions
Basisget_basis()
Basis of thetransform property. Represents the rotation, scale, and shear of this node.
Basisget_global_basis()
Global basis of this node. This is equivalent toglobal_transform.basis
.
Vector3get_global_position()
Global position of this node. This is equivalent toglobal_transform.origin
.
Vector3get_global_rotation()
Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
Note: In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in aVector3 data structure not because the rotation is a vector, but only becauseVector3 exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
Vector3global_rotation_degrees🔗
Vector3get_global_rotation_degrees()
Helper property to accessglobal_rotation in degrees instead of radians.
Transform3Dglobal_transform🔗
Transform3Dget_global_transform()
World3D space (global)Transform3D of this node.
Vector3position =Vector3(0,0,0)
🔗
Vector3get_position()
Local position or translation of this node relative to the parent. This is equivalent totransform.origin
.
Quaternionquaternion🔗
Quaternionget_quaternion()
Access to the node rotation as aQuaternion. This property is ideal for tweening complex rotations.
Vector3rotation =Vector3(0,0,0)
🔗
Vector3get_rotation()
Rotation part of the local transformation in radians, specified in terms of Euler angles. The angles construct a rotation in the order specified by therotation_order property.
Note: In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in aVector3 data structure not because the rotation is a vector, but only becauseVector3 exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, userotation_degrees.
Vector3get_rotation_degrees()
Helper property to accessrotation in degrees instead of radians.
RotationEditModerotation_edit_mode =0
🔗
RotationEditModeget_rotation_edit_mode()
Specify how rotation (and scale) will be presented in the editor.
EulerOrderrotation_order =2
🔗
EulerOrderget_rotation_order()
Specify the axis rotation order of therotation property. The final orientation is constructed by rotating the Euler angles in the order specified by this property.
Vector3get_scale()
Scale part of the local transformation.
Note: Mixed negative scales in 3D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, the scale values will either be all positive or all negative.
Note: Not all nodes are visually scaled by thescale property. For example,Light3Ds are not visually affected byscale.
boolis_set_as_top_level()
Iftrue
, the node will not inherit its transformations from its parent. Node transformations are only in global space.
Transform3Dtransform =Transform3D(1,0,0,0,1,0,0,0,1,0,0,0)
🔗
Transform3Dget_transform()
Local spaceTransform3D of this node, with respect to the parent node.
NodePathvisibility_parent =NodePath("")
🔗
NodePathget_visibility_parent()
Defines the visibility range parent for this node and its subtree. The visibility parent must be a GeometryInstance3D. Any visual instance will only be visible if the visibility parent (and all of its visibility ancestors) is hidden by being closer to the camera than its ownGeometryInstance3D.visibility_range_begin. Nodes hidden via thevisible property are essentially removed from the visibility dependency tree, so dependent instances will not take the hidden node or its ancestors into account.
boolis_visible()
Iftrue
, this node is drawn. The node is only visible if all of its ancestors are visible as well (in other words,is_visible_in_tree() must returntrue
).
Method Descriptions
voidadd_gizmo(gizmo:Node3DGizmo)🔗
Attach an editor gizmo to thisNode3D.
Note: The gizmo object would typically be an instance ofEditorNode3DGizmo, but the argument type is kept generic to avoid creating a dependency on editor classes inNode3D.
Clear all gizmos attached to thisNode3D.
voidclear_subgizmo_selection()🔗
Clears subgizmo selection for this node in the editor. Useful when subgizmo IDs become invalid after a property change.
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
Array[Node3DGizmo]get_gizmos()const🔗
Returns all the gizmos attached to thisNode3D.
Transform3Dget_global_transform_interpolated()🔗
When using physics interpolation, there will be circumstances in which you want to know the interpolated (displayed) transform of a node rather than the standard transform (which may only be accurate to the most recent physics tick).
This is particularly important for frame-based operations that take place inNode._process(), rather thanNode._physics_process(). Examples includeCamera3Ds focusing on a node, or finding where to fire lasers from on a frame rather than physics tick.
Note: This function creates an interpolation pump on theNode3D the first time it is called, which can respond to physics interpolation resets. If you get problems with "streaking" when initially following aNode3D, be sure to callget_global_transform_interpolated() at least oncebefore resetting theNode3D physics interpolation.
Node3Dget_parent_node_3d()const🔗
Returns the parentNode3D, ornull
if no parent exists, the parent is not of typeNode3D, ortop_level istrue
.
Note: Calling this method is not equivalent toget_parent()asNode3D
, which does not taketop_level into account.
Returns the currentWorld3D resource thisNode3D node is registered to.
voidglobal_rotate(axis:Vector3, angle:float)🔗
Rotates the global (world) transformation around axis, a unitVector3, by specified angle in radians. The rotation axis is in global coordinate system.
voidglobal_scale(scale:Vector3)🔗
Scales the global (world) transformation by the givenVector3 scale factors.
voidglobal_translate(offset:Vector3)🔗
Moves the global (world) transformation byVector3 offset. The offset is in global coordinate system.
Disables rendering of this node. Changesvisible tofalse
.
boolis_local_transform_notification_enabled()const🔗
Returns whether node notifies about its local transformation changes.Node3D will not propagate this by default.
Returns whether this node uses a scale of(1,1,1)
or its local transformation scale.
boolis_transform_notification_enabled()const🔗
Returns whether the node notifies about its global and local transformation changes.Node3D will not propagate this by default.
boolis_visible_in_tree()const🔗
Returnstrue
if the node is present in theSceneTree, itsvisible property istrue
and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree.
Visibility is checked only in parent nodes that inherit fromNode3D. If the parent is of any other type (such asNode,AnimationPlayer, orNode2D), it is assumed to be visible.
Note: This method does not takeVisualInstance3D.layers into account, so even if this method returnstrue
, the node might end up not being rendered.
voidlook_at(target:Vector3, up:Vector3 = Vector3(0, 1, 0), use_model_front:bool = false)🔗
Rotates the node so that the local forward axis (-Z,Vector3.FORWARD) points toward thetarget
position.
The local up axis (+Y) points as close to theup
vector as possible while staying perpendicular to the local forward axis. The resulting transform is orthogonal, and the scale is preserved. Non-uniform scaling may not work correctly.
Thetarget
position cannot be the same as the node's position, theup
vector cannot be zero.
Thetarget
and theup
cannot beVector3.ZERO, and shouldn't be colinear to avoid unintended rotation around local Z axis.
Operations take place in global space, which means that the node must be in the scene tree.
Ifuse_model_front
istrue
, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward thetarget
position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).
voidlook_at_from_position(position:Vector3, target:Vector3, up:Vector3 = Vector3(0, 1, 0), use_model_front:bool = false)🔗
Moves the node to the specifiedposition
, and then rotates the node to point toward thetarget
as perlook_at(). Operations take place in global space.
Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node'sTransform3D.
voidrotate(axis:Vector3, angle:float)🔗
Rotates the local transformation around axis, a unitVector3, by specified angle in radians.
voidrotate_object_local(axis:Vector3, angle:float)🔗
Rotates the local transformation around axis, a unitVector3, by specified angle in radians. The rotation axis is in object-local coordinate system.
Rotates the local transformation around the X axis by angle in radians.
Rotates the local transformation around the Y axis by angle in radians.
Rotates the local transformation around the Z axis by angle in radians.
voidscale_object_local(scale:Vector3)🔗
Scales the local transformation by given 3D scale factors in object-local coordinate system.
voidset_disable_scale(disable:bool)🔗
Sets whether the node uses a scale of(1,1,1)
or its local transformation scale. Changes to the local transformation scale are preserved.
Reset all transformations for this node (sets itsTransform3D to the identity matrix).
voidset_ignore_transform_notification(enabled:bool)🔗
Sets whether the node ignores notification that its transformation (global or local) changed.
voidset_notify_local_transform(enable:bool)🔗
Sets whether the node notifies about its local transformation changes.Node3D will not propagate this by default.
voidset_notify_transform(enable:bool)🔗
Sets whether the node notifies about its global and local transformation changes.Node3D will not propagate this by default, unless it is in the editor context and it has a valid gizmo.
voidset_subgizmo_selection(gizmo:Node3DGizmo, id:int, transform:Transform3D)🔗
Set subgizmo selection for this node in the editor.
Note: The gizmo object would typically be an instance ofEditorNode3DGizmo, but the argument type is kept generic to avoid creating a dependency on editor classes inNode3D.
Enables rendering of this node. Changesvisible totrue
.
Vector3to_global(local_point:Vector3)const🔗
Transformslocal_point
from this node's local space to world space.
Vector3to_local(global_point:Vector3)const🔗
Transformsglobal_point
from world space to this node's local space.
voidtranslate(offset:Vector3)🔗
Changes the node's position by the given offsetVector3.
Note that the translationoffset
is affected by the node's scale, so if scaled by e.g.(10,1,1)
, a translation by an offset of(2,0,0)
would actually add 20 (2*10
) to the X coordinate.
voidtranslate_object_local(offset:Vector3)🔗
Changes the node's position by the given offsetVector3 in local space.
Updates all theNode3D gizmos attached to this node.