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.
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.
| Attack | Selection task | Notes |
|---|---|---|
| Shockwave, explosion | Crimson Selection: Area | Sphere, Box or Capsule, centered on the actor, a socket, or the request's location |
| Hitscan shot | Crimson Selection: Trace | Line, Sphere, Capsule or Box swept out to Trace Length. Direction Mode chooses what it aims along |
| Cone or wedge | Crimson Selection: Area (Sphere) plus Crimson Filter: Angle | There 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 camera | Crimson Selection: Trace | Set Direction Mode to Mouse To World Projection for a cursor-aimed game, or Custom for a fixed direction in the actor's own space |
/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.
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 Mode | Points along | Use for |
|---|---|---|
Control Rotation | The source pawn's control rotation, or the actor's forward vector when it is not a pawn | First and third person shooting. Control rotation replicates, so the server and the owning client agree |
Mouse To World Projection | The point under the local player's cursor | Top-down and twin-stick aiming. Read the multiplayer note below before using it |
Custom | Custom Direction, rotated into the source actor's space | A fixed direction that is not where the player is looking - a ground slam tracing straight down, a backstep that sweeps behind |
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.
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.
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.
Hit zones and area attacks
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