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.

Node2D

Inherits: CanvasItem < Node < Object

Inherited By: AnimatedSprite2D, AudioListener2D, AudioStreamPlayer2D, BackBufferCopy, Bone2D, Camera2D, CanvasGroup, CanvasModulate, CollisionObject2D, CollisionPolygon2D, CollisionShape2D, CPUParticles2D, GPUParticles2D, Joint2D, Light2D, LightOccluder2D, Line2D, Marker2D, MeshInstance2D, MultiMeshInstance2D, NavigationLink2D, NavigationObstacle2D, NavigationRegion2D, ParallaxLayer, Path2D, PathFollow2D, Polygon2D, RayCast2D, RemoteTransform2D, ShapeCast2D, Skeleton2D, Sprite2D, TileMapLayerGroup, TouchScreenButton, VisibleOnScreenNotifier2D

A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.

Description

A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order.

Tutorials

Properties

Vector2

global_position

float

global_rotation

float

global_rotation_degrees

Vector2

global_scale

float

global_skew

Transform2D

global_transform

Vector2

position

Vector2(0, 0)

float

rotation

0.0

float

rotation_degrees

Vector2

scale

Vector2(1, 1)

float

skew

0.0

Transform2D

transform

Methods

void

apply_scale(ratio: Vector2)

float

get_angle_to(point: Vector2) const

Transform2D

get_relative_transform_to_parent(parent: Node) const

void

global_translate(offset: Vector2)

void

look_at(point: Vector2)

void

move_local_x(delta: float, scaled: bool = false)

void

move_local_y(delta: float, scaled: bool = false)

void

rotate(radians: float)

Vector2

to_global(local_point: Vector2) const

Vector2

to_local(global_point: Vector2) const

void

translate(offset: Vector2)


Property Descriptions

Vector2 global_position

  • void set_global_position(value: Vector2)

  • Vector2 get_global_position()

Global position.


float global_rotation

  • void set_global_rotation(value: float)

  • float get_global_rotation()

Global rotation in radians.


float global_rotation_degrees

  • void set_glob