Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Node3D

Inherits: Node < Object

Inherited By: AudioListener3D, AudioStreamPlayer3D, BoneAttachment3D, Camera3D, CollisionObject3D, CollisionPolygon3D, CollisionShape3D, GridMap, ImporterMeshInstance3D, Joint3D, LightmapProbe, Marker3D, NavigationLink3D, NavigationObstacle3D, NavigationRegion3D, OccluderInstance3D, OpenXRHand, Path3D, PathFollow3D, RayCast3D, RemoteTransform3D, ShapeCast3D, Skeleton3D, SpringArm3D, VehicleWheel3D, VisualInstance3D, XRNode3D, XROrigin3D

Most basic 3D game object, parent of all 3D-related nodes.

Description

Most basic 3D game object, with a Transform3D and visibility settings. All other 3D game objects inherit from Node3D. Use Node3D 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 the Node3D object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the Node3D's transform. The word local below refers to this coordinate system. The coordinate system that is attached to the Node3D object itself is referred to as object-local coordinate system.

Note: Unless otherwise specified, all methods that have angle parameters must have angles specified as radians. 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

Basis

basis

Basis

global_basis

Vector3

global_position

Vector3

global_rotation

Vector3

global_rotation_degrees

Transform3D

global_transform

Vector3

position

Vector3(0, 0, 0)

Quaternion

quaternion

Vector3

rotation

Vector3(0, 0, 0)

Vector3

rotation_degrees

RotationEditMode

rotation_edit_mode

0

EulerOrder

rotation_order

2

Vector3

scale

Vector3(1, 1, 1)

bool

top_level

false

Transform3D

transform

Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

NodePath

visibility_parent

NodePath("")

bool

visible

true

Methods

void

add_gizmo ( Node3DGizmo gizmo )

void

clear_gizmos ( )

void

clear_subgizmo_selection ( )

void

force_update_transform ( )

Node3DGizmo[]

get_gizmos ( ) const

Node3D

get_parent_node_3d ( ) const

World3D

get_world_3d ( ) const

void

global_rotate ( Vector3 axis, float angle )

void

global_scale ( Vector3 scale )

void

global_translate ( Vector3 offset )

void

hide ( )

bool

is_local_transform_notification_enabled ( ) const

bool

is_scale_disabled ( ) const

bool

is_transform_notification_enabled ( ) const

bool

is_visible_in_tree ( ) const

void

look_at ( Vector3 target, Vector3 up=Vector3(0, 1, 0), bool use_model_front=false )

void

look_at_from_position ( Vector3 position, Vector3 target, Vector3 up=Vector3(0, 1, 0), bool use_model_front=false )

void

orthonormalize ( )

void

rotate ( Vector3 axis, float angle )

void

rotate_object_local ( Vector3 axis, float angle )

void

rotate_x ( float angle )

void

rotate_y ( float angle )

void

rotate_z ( float angle )

void

scale_object_local ( Vector3 scale )

void

set_disable_scale ( bool disable )

void

set_identity ( )

void

set_ignore_transform_notification ( bool enabled )

void

set_notify_local_transform ( bool enable )

void

set_notify_transform ( bool enable )

void

set_subgizmo_selection ( Node3DGizmo gizmo, int id, Transform3D transform )

void

show ( )

Vector3

to_global ( Vector3 local_point ) const

Vector3

to_local ( Vector3 global_point ) const

void

translate ( Vector3 offset )

void

translate_object_local ( Vector3 offset )

void

update_gizmos ( )


Signals

visibility_changed ( )

Emitted when node visibility changes.


Enumerations

enum RotationEditMode:

RotationEditMode ROTATION_EDIT_MODE_EULER = 0

The rotation is edited using Vector3 Euler angles.

RotationEditMode ROTATION_EDIT_MODE_QUATERNION = 1

The rotation is edited using a Quaternion.

RotationEditMode ROTATION_EDIT_MODE_BASIS = 2

The rotation is edited using a Basis. 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 for NOTIFICATION_TRANSFORM_CHANGED to work, users first need to ask for it, with set_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 new World3D resource.

NOTIFICATION_EXIT_WORLD = 42

Node3D nodes receive this notification when they are unregistered from current World3D 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 for NOTIFICATION_LOCAL_TRANSFORM_CHANGED to work, users first need to ask for it, with set_notify_local_transform.


Property Descriptions

Basis basis

  • void set_basis ( Basis value )

  • Basis get_basis ( )

Direct access to the 3x3 basis of the transform property.


Basis global_basis

  • void set_global_basis ( Basis value )

  • Basis get_global_basis ( )

Global basis of this node. This is equivalent to global_transform.basis.


Vector3 global_position

  • void set_global_position ( Vector3 value )

  • Vector3 get_global_position ( )

Global position of this node. This is equivalent to global_transform.origin.


Vector3 global_rotation

  • void set_global_rotation ( Vector3 value )

  • Vector3 get_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 a Vector3 data structure not because the rotation is a vector, but only because Vector3 exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.


Vector3 global_rotation_degrees

  • void set_global_rotation_degrees ( Vector3 value )

  • Vector3 get_global_rotation_degrees ( )

Helper property to access global_rotation in degrees instead of radians.


Transform3D global_transform

World3D space (global) Transform3D of this node.


Vector3 position = Vector3(0, 0, 0)

Local position or translation of this node relative to the parent. This is equivalent to transform.origin.


Quaternion quaternion

Access to the node rotation as a Quaternion. This property is ideal for tweening complex rotations.


Vector3 rotation = Vector3(0, 0, 0)

Rotation part of the local transformation in radians, specified in terms of Euler angles. The angles construct a rotation in the order specified by the rotation_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 a Vector3 data structure not because the rotation is a vector, but only because Vector3 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, use rotation_degrees.


Vector3 rotation_degrees

  • void set_rotation_degrees ( Vector3 value )

  • Vector3 get_rotation_degrees ( )

Helper property to access rotation in degrees instead of radians.


RotationEditMode rotation_edit_mode = 0

Specify how rotation (and scale) will be presented in the editor.