Skip to main content
Glama

godot_update_node_transform

Modify node positions, rotations, and scales in Godot scene files to adjust object placement and orientation during game development.

Instructions

Update the transform section of a specific node in a saved scene. Currently supports Node2D, Node3D, and Control nodes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to the Godot project directory or its project.godot file.
scene_pathYesPath to the target .tscn file. Absolute, relative, and res:// paths are supported.
node_pathNoScene-relative node path to update. Use '.' for the root node..
transformYesTransform fields to update. Vector values can be passed as objects like {x, y} or {x, y, z}.
godot_executableNoOptional explicit path to the Godot executable or .app bundle.

Implementation Reference

  • Implementation of the update_node_transform tool in GodotController.
    def update_node_transform(
        self,
        project_path: str,
        scene_path: str,
        transform: dict[str, Any],
        node_path: str = ".",
        godot_executable: str | None = None,
    ) -> dict[str, Any]:
        project_dir = ensure_project_path(project_path)
        executable, version = resolve_godot_executable(godot_executable)
        absolute_scene_path, resource_scene_path = resolve_scene_path(project_dir, scene_path)
    
        if not absolute_scene_path.exists():
            raise GodotError(f"Scene not found: {absolute_scene_path}")
        if not isinstance(transform, dict):
            raise GodotError("`transform` must be an object.")
        if not transform:
            raise GodotError("`transform` must contain at least one field to update.")
    
        normalized_node_path = normalize_scene_node_path(node_path)
        try:
            with tempfile.NamedTemporaryFile(
                mode="w",
                encoding="utf-8",
                suffix="-godot-node-transform.json",
                delete=False,
            ) as handle:
                json.dump(transform, handle, ensure_ascii=False)
                updates_path = handle.name
        except TypeError as exc:
            raise GodotError("`transform` contains a value that could not be serialized to JSON.") from exc
    
        try:
            output = _run_godot_script(
                executable=executable,
                project_dir=project_dir,
                script_name="update_node_transform.gd",
                user_args=[
                    "--scene-path",
                    resource_scene_path,
                    "--node-path",
                    normalized_node_path,
                    "--updates-path",
                    updates_path,
                ],
            )
        finally:
            Path(updates_path).unlink(missing_ok=True)
    
        parsed = _parse_script_json_output(output, "update_node_transform.gd")
    
        return {
            "project_path": str(project_dir),
            "scene_path": str(absolute_scene_path),
            "scene_resource_path": resource_scene_path,
            "node_path": parsed.get("node_path", normalized_node_path),
            "node_name": parsed.get("node_name"),
            "node_type": parsed.get("node_type"),
            "transform_kind": parsed.get("transform_kind"),
            "supported_fields": parsed.get("supported_fields", []),
            "updated_fields": parsed.get("updated_fields", []),
            "transform": parsed.get("transform", {}),
            "godot_executable": str(executable),
            "godot_version": version,
        }
  • Registration of the godot_update_node_transform tool definition in the server.
        name="godot_update_node_transform",
        description="Update the transform section of a specific node in a saved scene. Currently supports Node2D, Node3D, and Control nodes.",
        input_schema={
            "type": "object",
            "properties": {
                "project_path": {
                    "type": "string",
                    "description": "Path to the Godot project directory or its project.godot file.",
                },
                "scene_path": {
                    "type": "string",
                    "description": "Path to the target .tscn file. Absolute, relative, and res:// paths are supported.",
                },
                "node_path": {
                    "type": "string",
                    "description": "Scene-relative node path to update. Use '.' for the root node.",
                    "default": ".",
                },
                "transform": {
                    "type": "object",
                    "description": "Transform fields to update. Vector values can be passed as objects like {x, y} or {x, y, z}.",
                },
                "godot_executable": {
                    "type": "string",
                    "description": "Optional explicit path to the Godot executable or .app bundle.",
                },
            },
            "required": ["project_path", "scene_path", "transform"],
            "additionalProperties": False,
        },
        handler=lambda args: self.controller.update_node_transform(
            project_path=args["project_path"],
            scene_path=args["scene_path"],
            node_path=args.get("node_path", "."),
            transform=args["transform"],
            godot_executable=args.get("godot_executable"),
        ),
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MhrnMhrn/godot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server