How-To: Area Attacks and Hitscan

Goal: build an attack with one moment of impact rather than a swing to follow - a shockwave, an explosion, a hitscan shot.

Prerequisites
Quick Start through step 5, so you have a component on the attacker. How-To: Get the Building Blocks for how to reach the component.

1. Pick the selection task

Both shapes ship in this plugin. The Targeting System has its own AOE and Trace tasks and they still work, but prefer the Crimson ones: they draw under this plugin's debug view, their dimensions can be varied per attack from the node, and they request the physical material a hit zone resolves from.

AttackSelection taskNotes
Shockwave, explosionCrimson Selection: AreaSphere, Box or Capsule, centered on the actor, a socket, or the request's location
Hitscan shotCrimson Selection: TraceLine, Sphere, Capsule or Box swept out to Trace Length. Direction Mode chooses what it aims along
Cone or wedgeCrimson Selection: Area (Sphere) plus Crimson Filter: AngleThere is no cone shape; a sphere trimmed by the angle filter is the same thing and reuses the arc rules
Shot that aims somewhere other than the cameraCrimson Selection: TraceSet Direction Mode to Mouse To World Projection for a cursor-aimed game, or Custom for a fixed direction in the actor's own space
Reference implementations
Two worked presets ship in /CrimsonHitDetection/Examples/, both paired with a ready profile:

TP_CrimsonAreaSphere - Crimson Selection: Area, a 300cm sphere centered on the caster. Used by DA_CrimsonHitProfile_Area.
TP_CrimsonHitscan - Crimson Selection: Trace, a 10m line forward from the shooter. Used by DA_CrimsonHitProfile_HitScan.

Both also carry Crimson Filter: Affiliation and Crimson Filter: Require Ability System. Unlike the melee preset these need no editing: area and trace geometry derives from the source actor rather than from named sockets, so they are drop-in.

Tick Settings > Show Plugin Content in the Content Browser to see them.
Verify
The preset has exactly one selection task at the top. The Hit Profile's Data Validation will tell you if it has none.

2. Aim the trace

Direction Mode on Crimson Selection: Trace decides what the shot points along. Set it on the task; you do not need a Blueprint subclass for any of the three.

Direction ModePoints alongUse for
Control RotationThe source pawn's control rotation, or the actor's forward vector when it is not a pawnFirst and third person shooting. Control rotation replicates, so the server and the owning client agree
Mouse To World ProjectionThe point under the local player's cursorTop-down and twin-stick aiming. Read the multiplayer note below before using it
CustomCustom Direction, rotated into the source actor's spaceA fixed direction that is not where the player is looking - a ground slam tracing straight down, a backstep that sweeps behind
Mouse To World Projection is resolved where the cursor is
A cursor exists on a local player controller and nowhere else. Detection runs on the server, so on a dedicated server, for a simulated proxy, or when the player is on a gamepad, there is no cursor to read and the trace falls back to Control Rotation - which replicates, so the shot still goes somewhere sensible rather than nowhere.

That fallback keeps the server authoritative, but it means the server and the client can disagree about the exact aim point. If an attack must land exactly where the cursor was, capture the aim on the client, send it to the server, and use Custom with that direction instead.

When none of the three fit, override the direction outright. Crimson Selection: Trace is Blueprintable, so both audiences can:

Right-click Crimson Selection: Trace in the Content Browser and pick Create Blueprint class based on this. In the new class, override Get Trace Direction and return a unit vector. Add that subclass to the preset in place of the base task.

The same override list covers Get Source Location, Get Source Offset, Get Trace Length, Get Swept Trace Radius, Get Swept Trace Capsule Half Height, Get Swept Trace Box Half Extents, Get Swept Trace Rotation and Get Additional Actors To Ignore. Each is called once per query.

Verify
Set Crimson.HitDetection.Debug 1 and fire. The trace draws as a blue arrow from the source out to Trace Length. Every shape except Line also draws itself at both ends of that arrow; a Line has no cross-section, so the arrow is all there is. Confirm it points where you expect before worrying about what it hits.

The shapes are drawn by the machine that runs the query, which is the server - so in Play As Client you see them in the host window, not the client's.

3. Fire a single query

Put a Crimson Hit Query (Notify) on the montage frame the blast lands. One frame needs no window - and a window is for something that sweeps through space, which a position-based area or trace does not do.

As always the notify carries only a Context Tag; the ability's Crimson Hit Query node arms the profile under that tag and hears the result.

On the montage: a Crimson Hit Query (Notify) at the impact frame, Context Tag = Attack.Slam.

In the ability graph: Event ActivateAbility -> Crimson Hit Query with Profile = your area profile and the same Context Tag, then Play Montage And Wait. Wire On Targets Hit to your effect application. Server only - it does not fire on clients.

Verify
Activate the ability with several enemies in range and confirm every one of them appears in the report exactly once. If nothing fires, check the output log for found no Hit Profile armed under Context Tag - that means the notify's tag and the node's tag disagree.

4. Limit how many targets it may hit

Set Max Targets Per Window on the profile. Add a sort task to the preset so the choice of which targets survive is deliberate: the Targeting System's Sort By Distance for nearest-first, or Crimson Sort: Angle for most-centered-on-the-attack.

Verify
The profile warns during Data Validation when a target limit is set without a sort task, because the survivors would otherwise be arbitrary.

Hit zones and area attacks

Area queries cannot resolve hit zones
Area selection overlaps, and an overlap result carries no impact point, no bone name and no physical material. An area attack therefore reports no hit zone and falls back to the target's location for its impact point. That is true of both Crimson Selection: Area and the Targeting System's AOE.

This is usually correct - an explosion should not land a head shot. Hitscan is different: Crimson Selection: Trace traces rather than overlaps and asks for the physical material, so it resolves zones normally. See How-To: Hit Zones.

See also

  • How-To: Hit Zones
  • Concept: Windows, Shapes and Filters
  • API Reference