Editor/Tools/WorkflowTools.NavigationAndAim.cs

An Editor MCP tool entry point that exposes camera and aim controls. It parses parameters like action, target, position, orientation and raycast distance, forwards them to CameraNavigationDriver.Navigate, and returns the result as JSON for the MCP system.

File Access
#nullable enable
using System;
using System.ComponentModel;

namespace Editor.Mcp
{
	public static partial class SboxMcpAssistant
	{
		/// <summary>
		/// Navigates the scene camera and controls player aim in both Edit Mode and Play Mode:
		/// fly/move to coordinates, look at specific GameObjects or 3D points, frame selections (FrameTo),
		/// and perform crosshair forward raycasts to inspect targets and distance.
		/// </summary>
		[McpTool( "pocketknife_camera_navigate" )]
		public static string CameraNavigate(
			[Description( "Action: 'status', 'fly', 'move', 'look_at', 'frame', 'raycast'" )] string action = "status",
			[Description( "Target GameObject name or GUID (for frame or look_at)" )] string? target = null,
			[Description( "Target absolute world position X" )] float? posX = null,
			[Description( "Target absolute world position Y" )] float? posY = null,
			[Description( "Target absolute world position Z" )] float? posZ = null,
			[Description( "Target camera pitch angle (-89 to 89)" )] float? pitch = null,
			[Description( "Target camera yaw angle" )] float? yaw = null,
			[Description( "Target camera roll angle" )] float? roll = null,
			[Description( "Relative delta move X" )] float? deltaX = null,
			[Description( "Relative delta move Y" )] float? deltaY = null,
			[Description( "Relative delta move Z" )] float? deltaZ = null,
			[Description( "Maximum raycast distance for forward probe (default 5000)" )] float maxRayDistance = 5000f )
		{
			try
			{
				var result = CameraNavigationDriver.Navigate(
					action,
					target,
					posX, posY, posZ,
					pitch, yaw, roll,
					deltaX, deltaY, deltaZ,
					maxRayDistance
				);
				return McpJson.Write( result );
			}
			catch ( Exception ex )
			{
				return McpJson.Write( ToolOutcome<object>.Failure( null, ToolStatus.Failed, "camera.navigate_failed", "Camera navigation failed.", ex ) );
			}
		}
	}
}