Debugging

Debugging Tools: Collision, Perception & Navigation

Many gameplay failures aren't in the logic you're testing. The enemy never attacked because a trigger sphere blocks its sight channel. The character stopped short because the navmesh has a gap. The pickup never fired because its profile doesn't overlap pawns. Specter asks the engine directly and answers in a sentence, so you can find these from a test (or a coding agent can) without opening the editor's collision panels or recompiling with debug draws.

Why Doesn't the AI See It?

aiPerceives(target)checks the target the way AI sight does: its sight radius (the lose-sight radius once it's seen), its view angle, whether it detects that team, and a trace on the channel AI sight uses. It returns the numbers and one line saying why.

const guard = world.actor('BP_Guard');
const intruder = await world.spawnActor('BP_Intruder', { location: { x: 900, y: 0, z: 100 } });

const seen = await guard.aiPerceives(intruder);
console.log(seen.reason);

The reasons it gives:

Perceived by sight.
Out of range: 2150 away, sight radius 1500.
Outside its view: 104 degrees off where it faces, peripheral vision angle 60.
Its sight doesn't detect Friendly actors (Detection By Affiliation).
Something's in the way: Blocked on VisionBlocker 412 along (of 900) by BP_Crate_C_2's
  StaticMeshComponent0 (StaticMeshComponent, collision profile BlockAll, object type WorldStatic).

It also returns the distance, the angle, the attitude (Friendly, Neutral, Hostile), the sight settings, when sight last sensed the target, and the trace itself.

What's in the Way

traceTo(target, { channel, fromEyes })traces a line from the actor to another actor or a point and reports the first thing that blocks it, with that component's collision profile and object type. Channels are named as your project names them: Visibility, Camera, one of your own trace or object channels, or AISightfor the channel the AI System's sight uses. A misspelled channel fails with the list of names it knows.

// What's between the turret's eyes and the player, on the channel its sight uses
const trace = await turret.traceTo(player, { channel: 'AISight' });   // from its eyes
if (!trace.clear) {
  console.log(trace.summary);
  console.log(trace.blockedBy?.actor, trace.blockedBy?.profile, trace.blockedBy?.responses);
}

// The line-of-sight check and matcher take a channel too
expect(await turret.hasLineOfSightTo(player, { channel: 'Camera' })).toBe(true);

Collision Settings

getCollisionResponses({ channel }) lists every collision component of an actor with its profile, whether it queries or simulates, whether it generates overlap events and affects navigation, and how it responds to each channel (or only the one you ask about).

const pickup = await world.spawnActor('BP_HealthPickup', { location: { x: 0, y: 0, z: 50 } });

// Every collision component: profile, object type, and its response to the channel asked about
const components = await pickup.getCollisionResponses({ channel: 'Pawn' });
const trigger = components.find((c) => c.component === 'PickupSphere');
expect(trigger?.responses['Pawn']).toBe('Overlap');

A common catch it shows: the engine's stock profiles only list the engine's channels. A channel your project adds takes its default response on them, and when that default is Block, a sphere set to OverlapAllDynamic still blocks it:

[
  { component: 'PickupSphere', componentClass: 'SphereComponent',
    profile: 'OverlapAllDynamic', collisionEnabled: 'QueryOnly', objectType: 'WorldDynamic',
    generatesOverlapEvents: true, canEverAffectNavigation: false,
    responses: { Character: 'Block' } },   // ← a project channel the profile never mentions
  ...
]

Overlaps

getOverlappingActors()lists what overlaps the actor now, component by component. The actor's own components overlapping each other are left out.

const zone = world.actor('BP_CaptureZone');
const { actors, overlaps } = await zone.getOverlappingActors();
// actors:   ['BP_Hero_C_0', 'BP_Minion_C_4']
// overlaps: [{ component: 'ZoneSphere', actor: 'BP_Hero_C_0', actorClass: 'BP_Hero_C', otherComponent: 'CollisionCylinder' }, ...]

The Engine's Warnings

Specter keeps the engine's warnings and errors from the start of each test: Blueprint runtime errors, failed attachments, missing assets, ensures. Repeats are folded into one line with a count. world.getEngineLog() reads them in a test.

const { entries, dropped } = await world.getEngineLog({ max: 50 });
for (const e of entries) {
  console.log(`[${e.seconds.toFixed(1)}s] ${e.verbosity} ${e.category}: ${e.message} ×${e.count}`);
}

Engine Errors Fail Tests

A test can pass every check while the engine logs an error nobody reads: a failed ensure, a Blueprint accessing nothing, an asset that didn't load. toHaveNoEngineErrors() checks one test; the failOnEngineErrors option (or SPECTER_FAIL_ON_ENGINE_ERRORS=1 on CI) checks every test, and fails one that passed its own checks. Errors only by default (warnings: true counts warnings too). The editor's own tooling lines (asset registry, shader compiler, content browser) are left out, and allow lists the lines that are fine: a log category, text in the line, or a pattern.

// One test: nothing red in the log while it ran (failed ensures count as errors)
await expect(world).toHaveNoEngineErrors();
await expect(world).toHaveNoEngineErrors({ allow: ['LogNavigation', /Asset .* not found/] });

// Every test: one that passed its own checks fails when the engine logged an error
// playwright.config.ts
export default defineConfig({
  use: { failOnEngineErrors: { allow: ['LogStreaming'] } },
});

State History and Stuck AI

Four times a second, Specter samples the actors a test spawned and the pawns the game spawned while it ran: location, facing, speed, health and their AI's path following. world.getStateHistory()reads it during the test, and it's saved as state.json next to the test's timeline preview frames when the test ends, so a failure can be read afterwards: where was everyone at 6.2 s?

// Every 0.25 s: location, yaw, speed, health and path following of the test's actors
const history = await world.getStateHistory({ from: 4, to: 8, actor: 'Minion' });
for (const sample of history.samples ?? []) {
  const m = sample.actors['BP_Minion_C_4'];
  console.log(sample.t, m?.at, m?.speed, m?.health, m?.move);
}

// The one sample nearest a moment
const atSix = await world.getStateHistory({ at: 6 });

An AI whose path following says it's moving but that hasn't moved for two seconds is marked stuck: a warning on the timeline at that moment, and a line in the failure report.

In Every Failure Report

When a GAS or AI matcher fails, its diagnostics report starts with anything the previous test left changed (a moved camera, a menu left open; see test isolation), and ends with the AIs that got stuck and the engine's latest warnings and errors, so the cause is often on the same screen as the failure:

⚠️  The previous test ("placing a prop shows the placement bar") left the game changed:
   • Left showing (not showing when it started): WBP_PlacementBar.
   If this test expects the starting state, reset it in the project's fixture or a beforeEach/afterEach.

🚧 AI that stood still while moving:
   • BP_Minion_C_4: moving to (4000, 0) but at (2180, 35) for 3.5s from 6.2s, still

⚠️ Engine warnings and errors since the last test (most recent last):
   [0.4s] Warning PIE: AttachTo: '…BP_Turret_C_1.CollisionCylinder' is not static, cannot attach
          '…PointLight3' which is static to it. Aborting.
   [2.9s] Error LogScript: Accessed None trying to read property TargetActor (×12)

Cleaning Up What the Game Spawned

Each test's cleanup removes what it spawned, and also what the game spawned while it ran: the units a spawner made, projectiles, the controllers of what the test spawned. So one test's leftovers don't walk into the next. The game's framework (player controllers, player states, the HUD and cameras) and anything owned by or attached to something that stays are kept, as are actors tagged Specter.Persistent.

Turn it off in Project Settings › Plugins › Specter › Test Runner › Clear Actors Spawned During Tests. clearAllSpawned reports how many of each it removed.