Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created June 23, 2024 06:10
Show Gist options
  • Save Shilo/2595c48b589e84112eb5b0c0f49af0bf to your computer and use it in GitHub Desktop.
Save Shilo/2595c48b589e84112eb5b0c0f49af0bf to your computer and use it in GitHub Desktop.
Godot EditorScript to align selected Node2Ds to current mouse position.
@tool
extends EditorScript
# Align selected Node2Ds to current mouse position.
# Ctrl+Shift+X to run.
func _run():
var editor_interface = get_editor_interface()
var mouse_position = editor_interface.get_editor_viewport_2d().get_mouse_position()
for selected_node in editor_interface.get_selection().get_selected_nodes():
if selected_node is Node2D:
selected_node.global_position = mouse_position
print("Aligned %s with mouse position." % selected_node)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment