Custom Targeters
Some orders need more than a right-click: where to put a building, how it faces, where a grenade lands, which line a barrage strafes. A targeter captures those points on the player’s machine, shows a preview while the player aims, and sends the captured points with the order.
Goal. Build three targeters on three abilities: a Bunker placed with a ghost that turns green or red, a Grenade with a ring showing its blast radius, and a Barrage that the player draws as a lane across the map.
Abilities explains targeters and the gates behind them. This page builds them.
Before you start. You need a unit with a Sein Abilities component, a HUD action button that calls Trigger Ability From Action Slot (Build the HUD), and a Bunker entity SU_Bunker with Sein Extents that has at least one shape. The ghost and the placement check both read those extents.
How the player uses a targeter: clicking the ability’s button opens it. Left click places a point, and for facing or a line, press, drag and release. Right click cancels. The preview runs on the player’s machine only. The simulation checks the order again when it runs.
1. A placement ghost
Section titled “1. A placement ghost”Create SA_PlaceBunker:
| Setting | Value |
|---|---|
| Ability Name | Build Bunker |
| Target Type | Point |
| Dispatch Mode | Single |
| Max Range | 400 |
| Out Of Range Behavior | Auto Move Then |
| Resource Cost | 100 Minerals |
| Requires Free Footprint | On |
| Footprint Actor Class | SU_Bunker |
| Cancel Abilities With Tag | SeinARTS.Ability |
| Targeter Spec | Point + Facing Targeter Spec |
Footprint Actor Class appears under Targeting once Requires Free Footprint is on. It does two jobs. The simulation checks that class’s extents against the ground and other buildings at the captured position and facing. The default ghost copies the class’s visible meshes. The class must be an entity class, with an entity bridge.
Expand Targeter Spec and set:
| Setting | Value |
|---|---|
| Rotation Step Degrees | 90 (0 turns freely) |
| Reject Click When Blocked | On (this spec’s default) |
With Reject Click When Blocked on, a press over a blocked spot is ignored, a release over one drops the drag, and the targeter stays open.
In the Event Graph, On Activate:
- If Targeter Points is empty, Cancel Ability. The cost returns.
- Spawn Entity: Actor Class
SU_Bunker, Spawn Transform from Get Targeter Point Transform of the first point, Owner Player ID from Get Entity Owner of Owner Entity. - End Ability.
The point’s yaw is the facing the player dragged, snapped to the step.
Tint the ghost
Section titled “Tint the ghost”The default ghost shows the Bunker’s own materials, so a free spot and a blocked one look the same. Make three materials, following Build Production Buildings: translucent, unlit, with an emissive color. Name the instances MI_GhostValid (green), MI_GhostWarning (amber) and MI_GhostBlocked (red).
Create a Blueprint BP_BunkerGhost with parent Sein Point Facing Targeter Preview. Select its Mesh Preview component. Set Valid to MI_GhostValid, Warning to MI_GhostWarning and Blocked to MI_GhostBlocked. A material left empty falls back to Valid.
Back in SA_PlaceBunker, set the spec’s Preview Class to BP_BunkerGhost.
To ghost a simpler shape than the finished Bunker, set the Mesh Preview’s Mesh Override, or its Source Class for a different actor. Both change only what is drawn. The extents the simulation checks stay those of Footprint Actor Class.
Make the real rule the authoritative one
Section titled “Make the real rule the authoritative one”The ghost can only check what the player’s machine can see: the footprint, and the spec’s own rules. The ground rules you care about, such as a range, a cost or “only near your headquarters”, belong in the ability, where the simulation checks them. Put the rule in Can Activate, or in the Valid Target Tags, Required Player Tags and Requires Pathable Target settings. A ghost that shows green for a spot the simulation will refuse is only a hint.
2. An area ring
Section titled “2. An area ring”A Grenade has no footprint. It needs a ring the size of its blast.
Create SA_Grenade from Abilities, or set any ability to Target Type Area with Area Radius 300 and Targeter Spec Point Targeter Spec.
Make a decal material M_AreaRingValid: Material Domain Deferred Decal, Blend Mode Translucent, a ring texture into Emissive Color and Opacity. Duplicate it as M_AreaRingBlocked in red.
Create BP_AreaRing with parent Sein Point Targeter Preview. Select its Decal Preview component. Set Valid to M_AreaRingValid and Blocked to M_AreaRingBlocked. Leave Use Area Radius on: the ring takes the ability’s Area Radius. When it is off, or the Area Radius is 0, Radius (60 by default) sets the size, and Projection Depth sets how far the decal reaches into the ground.
Set the spec’s Preview Class to BP_AreaRing. Until a preview class has materials, the built-in point preview draws nothing.
3. A line targeter
Section titled “3. A line targeter”A Barrage lands along a line the player draws, with a width.
Create SA_Barrage:
| Setting | Value |
|---|---|
| Ability Name | Barrage |
| Target Type | Point |
| Resource Cost | 75 Minerals |
| Cooldown | 30 |
| Cancel Abilities With Tag | SeinARTS.Ability |
| Targeter Spec | Line Targeter Spec |
Expand the spec:
| Setting | Value |
|---|---|
| Capture Mode | Drag |
| Target Count | 1 (the number of segments) |
| Width | 400 |
| Max Segment Length | 2500 |
| Validate Corridor Fit | On |
| Reject Click When Blocked | On |
Capture Mode Drag captures one segment per press, drag and release. Multi Click plants a vertex on each click and chains segments, for walls or trenches. Clicking within Finish Click Tolerance of the last vertex submits early.
Validate Corridor Fit samples the line against the navigation grid. A line crossing impassable ground is Blocked; a lane whose edges clip impassable cells is a Warning. Turn it off for artillery that fires over walls. Max Segment Length marks a longer segment Blocked.
The lane preview
Section titled “The lane preview”Make a decal material M_BarrageLane: Material Domain Deferred Decal, Blend Mode Translucent, a Vector Parameter named TintColor into Emissive Color, and a constant 0.35 for Opacity. The preview sets TintColor green, amber or red by validity.
Create BP_BarrageLane with parent Sein Line Targeter Preview. Select the inherited Segment Decal component and set its Decal Material to M_BarrageLane. The preview stretches the decal from the press to the cursor, Width wide. A thin line shows when Width is 0, sized by Default Line Half Width. Segments already captured stay on screen until the session ends.
Set the spec’s Preview Class to BP_BarrageLane.
Read the segment
Section titled “Read the segment”In On Activate, Targeter Points holds one entry per segment. For each, Break Sein Targeter Point gives Location, the start, and Aux Location, the end.
- Take
Delta, the end minus the start, with the fixed-vector Subtract node. - Max Segment Length is checked only on the player’s machine. The simulation does not repeat it, so check it here: if Dot Product of
Deltawith itself is above2500 × 2500, Cancel Ability. The cost returns. - For Loop from
0to7: the position is the start plusDeltatimes the index over7, using Multiply, Divide and Add. - At each position, run the damage routine from the Grenade, with the corridor’s half width,
Width ÷ 2(cast Targeter Spec to Line Targeter Spec and read Width), as the query Range. - End Ability.
Width is authored on the spec and identical on every machine, so reading it in the simulation is safe.
4. Test
Section titled “4. Test”Grant the three abilities and give the unit HUD buttons. Play:
- Click Build Bunker. A ghost follows the cursor, green on open ground. Move it onto an existing building: red. Click there: nothing happens, and the targeter stays open.
- Press on open ground and drag. The ghost turns in 90 degree steps. Release: the Bunker appears facing that way and Minerals drop by 100. From more than 400 units away, the unit first walks to the captured point itself.
- Right-click while aiming: the targeter closes, and nothing is paid.
- Click Throw Grenade. A ring 300 units in radius follows the cursor.
- Click Barrage, then press, drag across open ground and release. A 400-wide lane stretches under the cursor. Drag more than 2,500 units and it turns red, and the release is ignored. Drag across impassable ground and it turns red with Validate Corridor Fit on.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause |
|---|---|
| The button does nothing, and the log warns that the TargeterSpec is null | A Point, Area or Entity ability with no Targeter Spec |
| The ghost never appears | Footprint Actor Class is not set, or it has no visible mesh components. The ghost copies static and skeletal meshes; meshes starting hidden are skipped. |
| The ghost is always red | Footprint Actor Class has no Sein Extents shapes, or is not set. An ability with Requires Free Footprint and no class rejects every spot. |
| A compile warning, or a match that will not start, names a Footprint Actor Class | The class has no entity bridge. Use an entity class. |
| The ghost is green, but the order is rejected | The preview does not check range, cost, tags or pathing. Turn on Log LogSeinSim Verbose and read which gate refused it. |
| The lane decal is invisible | Segment Decal has no material, or the material’s domain is not Deferred Decal |
| The lane does not change color | The material has no TintColor vector parameter. It draws, untinted. |
| The area ring is the wrong size or missing | Use Area Radius is off, the ability’s Area Radius is 0, or Decal Preview has no Valid material |
| A click is ignored | Reject Click When Blocked is on and the cursor is over a Blocked spot |
Related
Section titled “Related”- Abilities: the gates, Target Types and the Targeter Points array.
- Build Production Buildings: placement in the demo.
- Gameplay Tags
- Sein Targeter Spec, Line Targeter Spec, Sein Targeter Preview