Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- AnimatedSprite2D
- AudioListener2D
- AudioStreamPlayer2D
- BackBufferCopy
- Bone2D
- CPUParticles2D
- Camera2D
- CanvasGroup
- CanvasModulate
- CollisionObject2D (2)
- CollisionPolygon2D
- CollisionShape2D
- GPUParticles2D
- Joint2D (3)
- Light2D (2)
- LightOccluder2D
- Line2D
- Marker2D
- MeshInstance2D
- MultiMeshInstance2D
- NavigationLink2D
- NavigationObstacle2D
- NavigationRegion2D
- Parallax2D
- ParallaxLayer
- Path2D
- PathFollow2D
- Polygon2D
- RayCast2D
- RemoteTransform2D
- ShapeCast2D
- Skeleton2D
- Sprite2D
- TileMap
- TileMapLayer
- TouchScreenButton
- VisibleOnScreenNotifier2D (1)
Table of contents
-
var global_position: Vector2 -
var global_rotation: float -
var global_rotation_degrees: float -
var global_scale: Vector2 -
var global_skew: float -
var global_transform: Transform2D -
var position: Vector2 = Vector2(0, 0) -
var rotation: float = 0.0 -
var rotation_degrees: float -
var scale: Vector2 = Vector2(1, 1) -
var skew: float = 0.0 -
var transform: Transform2D -
func apply_scale(ratio: Vector2) -> void -
const func get_angle_to(point: Vector2) -> float -
const func get_relative_transform_to_parent(parent: Node) -> Transform2D -
func global_translate(offset: Vector2) -> void -
func look_at(point: Vector2) -> void -
func move_local_x(scaled: bool = false) -> void -
func move_local_y(scaled: bool = false) -> void -
func rotate(radians: float) -> void -
const func to_global(local_point: Vector2) -> Vector2 -
const func to_local(global_point: Vector2) -> Vector2 -
func translate(offset: Vector2) -> void
Node2D #
is_instantiable, Node2D, Node, core, not_builtin_classes
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and skew.
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.
Note: Since both Node2D and Control inherit from CanvasItem, they share several concepts from the class such as the CanvasItem.z_index and CanvasItem.visible properties.
Members #
var global_position: Vector2#
Global position. See also position.
var global_rotation: float#
Global rotation in radians. See also rotation.
var global_rotation_degrees: float#
Helper property to access global_rotation in degrees instead of radians. See also rotation_degrees.
var global_scale: Vector2#
Global scale. See also scale.
var global_skew: float#
Global skew in radians. See also skew.
var global_transform: Transform2D#
Global Transform2D. See also transform.
var position: Vector2 = Vector2(0, 0)#
Position, relative to the node's parent. See also global_position.
var rotation: float = 0.0#
Rotation in radians, relative to the node's parent. See also global_rotation.
Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use rotation_degrees.
var rotation_degrees: float#
Helper property to access rotation in degrees instead of radians. See also global_rotation_degrees.
var scale: Vector2 = Vector2(1, 1)#
The node's scale, relative to the node's parent. Unscaled value: (1, 1). See also global_scale.
Note: Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
var skew: float = 0.0#
If set to a non-zero value, slants the node in one direction or another. This can be used for pseudo-3D effects. See also global_skew.
Note: Skew is performed on the X axis only, and between rotation and scaling.
Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use skew = deg_to_rad(value_in_degrees).
var transform: Transform2D#
The node's Transform2D, relative to the node's parent. See also global_transform.
Methods #
func apply_scale(ratio: Vector2) -> void#
Multiplies the current scale by the ratio vector.
const func get_angle_to(point: Vector2) -> float#
Returns the angle between the node and the point in radians.
const func get_relative_transform_to_parent(parent: Node) -> Transform2D#
Returns the Transform2D relative to this node's parent.
func global_translate(offset: Vector2) -> void#
Adds the offset vector to the node's global position.
func look_at(point: Vector2) -> void#
Rotates the node so that its local +X axis points towards the point, which is expected to use global coordinates.
point should not be the same as the node's position, otherwise the node always looks to the right.
func move_local_x(scaled: bool = false) -> void#
Applies a local translation on the node's X axis based on the Node._process's delta. If scaled is false, normalizes the movement.
func move_local_y(scaled: bool = false) -> void#
Applies a local translation on the node's Y axis based on the Node._process's delta. If scaled is false, normalizes the movement.
func rotate(radians: float) -> void#
Applies a rotation to the node, in radians, starting from its current rotation.
const func to_global(local_point: Vector2) -> Vector2#
Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the Node2D it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position.
const func to_local(global_point: Vector2) -> Vector2#
Transforms the provided global position into a position in local coordinate space. The output will be local relative to the Node2D it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.
func translate(offset: Vector2) -> void#
Translates the node by the given offset in local coordinates.