Skip to main content
Glama

editor_move_camera

Position the viewport camera at specified coordinates and angles to capture screenshots from precise perspectives in Unreal Engine.

Instructions

Move the viewport camera to a specific location and rotation for positioning screenshots

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesCamera world position coordinates
rotationYesCamera rotation in degrees

Implementation Reference

  • Python script implementing the camera movement logic using Unreal Engine's EditorLevelLibrary to set viewport camera position and rotation.
    import unreal
    import json
    
    
    def move_viewport_camera(location, rotation):
        try:
            location_vector = unreal.Vector(
                location["x"], location["y"], location["z"]
            )
            rotation_rotator = unreal.Rotator(
                rotation["roll"], rotation["pitch"], rotation["yaw"]
            )
    
            unreal.EditorLevelLibrary.set_level_viewport_camera_info(
                location_vector, rotation_rotator
            )
    
            return {
                "success": True,
                "location": {
                    "x": location["x"],
                    "y": location["y"],
                    "z": location["z"],
                },
                "rotation": {
                    "pitch": rotation["pitch"],
                    "yaw": rotation["yaw"],
                    "roll": rotation["roll"],
                },
            }
    
        except Exception as e:
            return {"success": False, "error": str(e)}
    
    
    location_data = ${location}
    rotation_data = ${rotation}
    
    if location_data and rotation_data:
        result = move_viewport_camera(location_data, rotation_data)
        print(json.dumps(result))
    else:
        print(
            json.dumps(
                {"success": False, "error": "Location and rotation parameters are required"}
            )
        )
  • MCP tool registration for 'editor_move_camera', including Zod input schema for location and rotation objects, and thin handler that runs the templated Python script via Unreal remote execution.
    server.tool(
    	"editor_move_camera",
    	"Move the viewport camera to a specific location and rotation for positioning screenshots",
    	{
    		location: z
    			.object({
    				x: z.number(),
    				y: z.number(),
    				z: z.number(),
    			})
    			.describe("Camera world position coordinates"),
    		rotation: z
    			.object({
    				pitch: z.number(),
    				yaw: z.number(),
    				roll: z.number(),
    			})
    			.describe("Camera rotation in degrees"),
    	},
    	async ({ location, rotation }) => {
    		const result = await tryRunCommand(editorTools.UEMoveCamera(location, rotation))
    		return {
    			content: [
    				{
    					type: "text",
    					text: result,
    				},
    			],
    		}
    	},
    )
  • Helper function that reads the ue_move_camera.py template and substitutes the location and rotation parameters as JSON strings using the Template utility.
    export const UEMoveCamera = (
    	location: { x: number; y: number; z: number },
    	rotation: { pitch: number; yaw: number; roll: number },
    ) => {
    	return Template(read("./scripts/ue_move_camera.py"), {
    		location: JSON.stringify(location),
    		rotation: JSON.stringify(rotation),
    	})
    }

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/runreal/unreal-mcp'

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