Skip to main content

Node2D

Inherits: CanvasItem < Node < Object

Description

A 2D game object with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D.

Properties

Vector2
default:"Vector2(0, 0)"
Position, relative to the node’s parent.
float
default:"0.0"
Rotation in radians, relative to the node’s parent.
Vector2
default:"Vector2(1, 1)"
The node’s scale. Unscaled value: (1, 1).
Vector2
Global position. See also position.

Methods

rotate

Applies a rotation to the node, in radians.

translate

Translates the node by the given offset in local coordinates.

look_at

Rotates the node so that its local +X axis points towards the point.

get_angle_to

Returns the angle between the node and the point in radians.

Example Usage