docs/manage-physics-patch.md
A new manage_physics MCP tool that gives AI assistants full control over Unity's 3D and 2D physics systems. 21 actions across 9 categories, with C# Editor implementation, Python MCP service, CLI commands, and tests.
| Action | Description |
|---|---|
ping | Health check — returns gravity, solver settings, simulation mode |
get_settings | Read physics project settings (3D or 2D) |
set_settings | Write physics project settings (gravity, solver iterations, thresholds, etc.) |
| Action | Description |
|---|---|
get_collision_matrix | Read per-layer collision matrix |
set_collision_matrix | Enable/disable collision between layer pairs |
| Action | Description |
|---|---|
create_physics_material | Create PhysicMaterial (3D) or PhysicsMaterial2D assets with friction/bounciness/combine modes |
configure_physics_material | Update properties on an existing physics material asset |
assign_physics_material | Assign a physics material to a GameObject's collider |
| Action | Description |
|---|---|
add_joint | Add a joint (hinge, spring, fixed, configurable, etc.) with optional connected body |
configure_joint | Configure motor, limits, spring, drive, and direct properties on an existing joint |
remove_joint | Remove joint(s) from a GameObject by type or all |
| Action | Description |
|---|---|
raycast | Single-hit raycast from origin along direction |
raycast_all | Multi-hit raycast returning all intersections |
linecast | Check if anything intersects the line between two points |
shapecast | Cast a shape (sphere, box, capsule) along a direction |
overlap | Find all colliders within a shape (sphere, box, capsule) at a position |
| Action | Description |
|---|---|
apply_force | Apply force, torque (or both), force-at-position, or explosion force to Rigidbodies. Supports all ForceModes for 3D and 2D |
| Action | Description |
|---|---|
get_rigidbody | Read full Rigidbody state: mass, velocity, position, rotation, damping, constraints, sleep state, centerOfMass |
configure_rigidbody | Set Rigidbody properties (mass, damping, gravity, kinematic, interpolation, collision detection, constraints) |
| Action | Description |
|---|---|
validate | Scan scene (or a single target) for physics issues. Paginated results (page_size/cursor/next_cursor) with per-category summary. 7 check categories: non-convex mesh, missing rigidbody, non-uniform scale, fast object with discrete detection, missing physics material, collision matrix, mixed 2D/3D. Smart warning levels — static colliders without Rigidbodies are downgraded to [Info] unless the object has an Animator |
| Action | Description |
|---|---|
simulate_step | Step physics simulation in Edit mode (1–100 steps). Returns positions, velocities, and angular velocities of active Rigidbodies after stepping. Optional target to filter to a specific object |
MCPForUnity/Editor/Tools/Physics/| File | Purpose |
|---|---|
ManagePhysics.cs | Action dispatcher with [McpForUnityTool] registration |
PhysicsSettingsOps.cs | ping, get_settings, set_settings |
CollisionMatrixOps.cs | get_collision_matrix, set_collision_matrix |
PhysicsMaterialOps.cs | create, configure, assign physics materials |
JointOps.cs | add_joint, configure_joint, remove_joint |
PhysicsQueryOps.cs | raycast, raycast_all, linecast, shapecast, overlap |
PhysicsForceOps.cs | apply_force (normal, explosion, torque) |
PhysicsRigidbodyOps.cs | get_rigidbody, configure_rigidbody |
PhysicsValidationOps.cs | validate with pagination and smart warnings |
PhysicsSimulationOps.cs | simulate_step with state reporting |
| File | Purpose |
|---|---|
Server/src/services/tools/manage_physics.py | MCP tool definition with 21-action Literal type, forwards all params to Unity |
Server/src/cli/commands/physics.py | Full CLI with commands for every action category |
Server/tests/test_manage_physics.py | 19 unit tests covering action forwarding and validation |
| File | Purpose |
|---|---|
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManagePhysicsTests.cs | 973-line EditMode test suite |
dimension override#if UNITY_6000_0_OR_NEWER for renamed APIs (drag → linearDamping, angularDrag → angularDamping)[Info]