Trace a line
traceCasts a single line segment between two points in a loaded GMod map to detect hits and return position, surface, entity, and collision details.
Instructions
One util.TraceLine from start to end. Result: hit, hit_world, hit_sky, hit_nodraw, pos (hit position, or end if nothing was hit), normal, fraction (0..1 along the segment), distance (to the hit, or the whole length), mat_type + mat_name (MAT_* constant), surfaceprop (name) + surfaceprop_id, texture, entity (summary, {id: 0, class: worldspawn} for the world, or null), start_solid, all_solid, fraction_left_solid, hitgroup, physics_bone. Example: {"start": [0, 0, 64], "end": [0, 0, -1000]}. For everything a segment crosses (walls, doors, thickness), use trace_through. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"start": "<start>",
"end": "<end>"
},
"name": "trace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | End, [x, y, z] in Hammer units. | |
| mask | No | Content mask: MASK_SOLID (default), MASK_SHOT, MASK_SHOT_HULL, MASK_SOLID_BRUSHONLY, MASK_PLAYERSOLID, MASK_PLAYERSOLID_BRUSHONLY, MASK_NPCSOLID, MASK_WATER, MASK_VISIBLE, MASK_OPAQUE, MASK_ALL, or the number. | |
| realm | No | Realm (default server). | |
| start | Yes | Start, [x, y, z] in Hammer units. | |
| filter | No | Entity indexes the trace ignores (e.g. the player). | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hit | Yes | ||
| pos | Yes | ||
| next | No | ||
| note | No | ||
| entity | No | ||
| normal | No | ||
| hit_sky | No | ||
| texture | No | ||
| warning | No | ||
| distance | Yes | ||
| fraction | Yes | ||
| hitgroup | No | ||
| mat_name | No | ||
| mat_type | No | ||
| all_solid | No | ||
| hit_world | No | ||
| next_call | No | ||
| hit_nodraw | No | ||
| answered_by | No | ||
| start_solid | No | ||
| surfaceprop | No | ||
| physics_bone | No | ||
| surfaceprop_id | No | ||
| truncated_note | No | ||
| version_warning | No | ||
| fraction_left_solid | No |