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
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | Camera world position coordinates | |
| rotation | Yes | Camera 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"} ) )
- server/index.ts:495-525 (registration)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, }, ], } }, )
- server/editor/tools.ts:80-88 (helper)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), }) }